mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-01 19:50:37 +00:00
Add test for clickStartQuest
This commit is contained in:
parent
861a90a562
commit
7f834429ac
1 changed files with 45 additions and 0 deletions
|
|
@ -127,4 +127,49 @@ describe("Party Controller", function() {
|
|||
abortSpy.should.not.have.been.calledOnce;
|
||||
});
|
||||
});
|
||||
|
||||
describe('clickStartQuest', function() {
|
||||
beforeEach(function() {
|
||||
sandbox.stub(rootScope, 'openModal');
|
||||
sandbox.stub(rootScope.$state, 'go');
|
||||
});
|
||||
|
||||
it('opens quest modal if user has a quest', function() {
|
||||
user.items.quests = {
|
||||
whale: 1
|
||||
};
|
||||
|
||||
scope.clickStartQuest();
|
||||
|
||||
expect(rootScope.$state.go).to.not.be.called;
|
||||
expect(rootScope.openModal).to.be.calledOnce;
|
||||
expect(rootScope.openModal).to.be.calledWith(
|
||||
'ownedQuests',
|
||||
{ controller: 'InventoryCtrl' }
|
||||
);
|
||||
});
|
||||
|
||||
it('does not open modal if user has no quests', function() {
|
||||
user.items.quests = { };
|
||||
|
||||
scope.clickStartQuest();
|
||||
|
||||
expect(rootScope.openModal).to.not.be.called;
|
||||
expect(rootScope.$state.go).to.be.calledOnce;
|
||||
expect(rootScope.$state.go).to.be.calledWith('options.inventory.quests');
|
||||
});
|
||||
|
||||
it('does not open modal if user had quests previously, but does not now', function() {
|
||||
user.items.quests = {
|
||||
whale: 0,
|
||||
atom1: 0
|
||||
};
|
||||
|
||||
scope.clickStartQuest();
|
||||
|
||||
expect(rootScope.openModal).to.not.be.called;
|
||||
expect(rootScope.$state.go).to.be.calledOnce;
|
||||
expect(rootScope.$state.go).to.be.calledWith('options.inventory.quests');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue