Adjustments to PR #5298

* Put watch on $scope
* Check for quest.completed !== true or false
* Add test for quest invite modal watch
This commit is contained in:
Blade Barringer
2015-06-20 21:10:18 -05:00
parent 19f8ca7980
commit 4fc04fea24
2 changed files with 65 additions and 1 deletions

View File

@@ -0,0 +1,64 @@
'use strict';
describe('Notification Controller', function() {
var user, scope, rootScope, ctrl;
beforeEach(function() {
user = specHelper.newUser();
user._id = "unique-user-id";
module(function($provide) {
$provide.value('User', {user: user});
$provide.value('Guide', {});
});
inject(function(_$rootScope_, _$controller_) {
scope = _$rootScope_.$new();
rootScope = _$rootScope_;
// Load RootCtrl to ensure shared behaviors are loaded
_$controller_('RootCtrl', {$scope: scope, User: {user: user}});
ctrl = _$controller_('NotificationCtrl', {$scope: scope, User: {user: user}});
});
});
describe('Quest Invitation modal watch', function() {
beforeEach(function() {
sandbox.stub(rootScope, 'openModal');
});
it('opens quest invitation modal', function() {
user.party.quest.RSVPNeeded = true;
delete user.party.quest.completed;
scope.$digest();
expect(rootScope.openModal).to.be.calledOnce;
expect(rootScope.openModal).to.be.calledWith('questInvitation', {controller:'PartyCtrl'});
});
it('does not open quest invitation modal if RSVPNeeded is not true', function() {
user.party.quest.RSVPNeeded = false;
user.party.quest.completed = false;
scope.$digest();
expect(rootScope.openModal).to.not.be.called;
});
it('does not open quest invitation modal if quest completed is set to false', function() {
user.party.quest.RSVPNeeded = true;
user.party.quest.completed = false;
scope.$digest();
expect(rootScope.openModal).to.not.be.called;
});
it('does not open quest invitation modal if quest completed is set to true', function() {
user.party.quest.RSVPNeeded = true;
user.party.quest.completed = true;
scope.$digest();
expect(rootScope.openModal).to.not.be.called;
});
});
});