mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
First root controller test
This commit is contained in:
32
test/spec/rootCtrlSpec.js
Normal file
32
test/spec/rootCtrlSpec.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
describe('Root Controller', function() {
|
||||||
|
var scope, user, ctrl;
|
||||||
|
|
||||||
|
beforeEach(module('habitrpg'));
|
||||||
|
beforeEach(inject(function($rootScope, $controller) {
|
||||||
|
scope = $rootScope.$new();
|
||||||
|
scope.loginUsername = 'user'
|
||||||
|
scope.loginPassword = 'pass'
|
||||||
|
user = specHelper.newUser();
|
||||||
|
|
||||||
|
ctrl = $controller('RootCtrl', {$scope: scope, User: {user: user}});
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('shows contributor level text', function(){
|
||||||
|
expect(scope.contribText()).to.eql(undefined);
|
||||||
|
expect(scope.contribText(null, {npc: 'NPC'})).to.eql('NPC');
|
||||||
|
expect(scope.contribText({level: 0, text: 'Blacksmith'})).to.eql(undefined);
|
||||||
|
expect(scope.contribText({level: 1, text: 'Blacksmith'})).to.eql('Friend Blacksmith');
|
||||||
|
expect(scope.contribText({level: 2, text: 'Blacksmith'})).to.eql('Friend Blacksmith');
|
||||||
|
expect(scope.contribText({level: 3, text: 'Blacksmith'})).to.eql('Elite Blacksmith');
|
||||||
|
expect(scope.contribText({level: 4, text: 'Blacksmith'})).to.eql('Elite Blacksmith');
|
||||||
|
expect(scope.contribText({level: 5, text: 'Blacksmith'})).to.eql('Champion Blacksmith');
|
||||||
|
expect(scope.contribText({level: 6, text: 'Blacksmith'})).to.eql('Champion Blacksmith');
|
||||||
|
expect(scope.contribText({level: 7, text: 'Blacksmith'})).to.eql('Legendary Blacksmith');
|
||||||
|
expect(scope.contribText({level: 8, text: 'Blacksmith'})).to.eql('Heroic Blacksmith');
|
||||||
|
expect(scope.contribText({level: 8, text: 'Blacksmith'}, {npc: 'NPC'})).to.eql('NPC');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
29
test/spec/specHelper.js
Normal file
29
test/spec/specHelper.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
specHelper = {
|
||||||
|
newUser: function(){
|
||||||
|
var buffs = {per:0, int:0, con:0, str:0, stealth: 0, streaks: false};
|
||||||
|
user = {
|
||||||
|
auth:{timestamps: {}},
|
||||||
|
stats: {str:1, con:1, per:1, int:1, mp: 32, class: 'warrior', buffs: buffs},
|
||||||
|
items:{
|
||||||
|
lastDrop:{count: 0},
|
||||||
|
hatchingPotions: {},
|
||||||
|
eggs: {},
|
||||||
|
food: {},
|
||||||
|
pets: {},
|
||||||
|
gear: {equipped: {}, costume: {}},
|
||||||
|
},
|
||||||
|
party: {
|
||||||
|
quest: {
|
||||||
|
progress: {down: 0}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
preferences: {},
|
||||||
|
dailys: [],
|
||||||
|
todos: [],
|
||||||
|
rewards: [],
|
||||||
|
flags: {},
|
||||||
|
achievements: {},
|
||||||
|
};
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user