mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Organized spec folder
This commit is contained in:
56
test/spec/controllers/headerCtrlSpec.js
Normal file
56
test/spec/controllers/headerCtrlSpec.js
Normal file
@@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
|
||||
describe('Header Controller', function() {
|
||||
var scope, ctrl, user, $location, $rootScope;
|
||||
|
||||
beforeEach(function() {
|
||||
module(function($provide) {
|
||||
$provide.value('User', {});
|
||||
});
|
||||
|
||||
inject(function(_$rootScope_, _$controller_, _$location_){
|
||||
user = specHelper.newUser();
|
||||
user._id = "unique-user-id"
|
||||
|
||||
scope = _$rootScope_.$new();
|
||||
$rootScope = _$rootScope_;
|
||||
|
||||
$location = _$location_;
|
||||
|
||||
// Load RootCtrl to ensure shared behaviors are loaded
|
||||
_$controller_('RootCtrl', {$scope: scope, User: {user: user}});
|
||||
|
||||
ctrl = _$controller_('HeaderCtrl', {$scope: scope, User: {user: user}});
|
||||
});
|
||||
});
|
||||
|
||||
context('inviteOrStartParty', function(){
|
||||
beforeEach(function(){
|
||||
sinon.stub($location, 'path');
|
||||
sinon.stub($rootScope, 'openModal');
|
||||
});
|
||||
|
||||
afterEach(function(){
|
||||
$location.path.restore();
|
||||
$rootScope.openModal.restore();
|
||||
});
|
||||
|
||||
it('redirects to party page if user does not have a party', function(){
|
||||
var group = {};
|
||||
scope.inviteOrStartParty(group);
|
||||
|
||||
expect($location.path).to.be.calledWith("/options/groups/party");
|
||||
expect($rootScope.openModal).to.not.be.called;
|
||||
});
|
||||
|
||||
it('Opens invite-friends modal if user has a party', function(){
|
||||
var group = {
|
||||
type: 'party'
|
||||
};
|
||||
scope.inviteOrStartParty(group);
|
||||
|
||||
expect($rootScope.openModal).to.be.calledOnce;
|
||||
expect($location.path).to.not.be.called;
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user