Repair remaining Karma specs - all passing.

* Stubbed out User module to repair rootCtrlSpec

* Loaded RootCtrl in inventoryCtrlSpec, as it was missing shared functions.
  Updated mock user to include a mounts hash.
This commit is contained in:
Kevin Gisi
2015-03-22 21:56:01 -04:00
parent 2194caec15
commit 1e59336d09
2 changed files with 38 additions and 24 deletions

View File

@@ -1,14 +1,17 @@
'use strict'; 'use strict';
// @TODO Address why translations aren't loading
// Possibly related to https://github.com/HabitRPG/habitrpg/commit/5aa401524934e6d9071f13cb2ccca0dba13cdcff
describe('Inventory Controller', function() { describe('Inventory Controller', function() {
var scope, ctrl, user, $rootScope; var scope, ctrl, user, $rootScope;
beforeEach(inject(function($rootScope, $controller, Shared){ beforeEach(function() {
module(function($provide) {
$provide.value('User', {});
});
inject(function($rootScope, $controller, Shared){
user = specHelper.newUser(); user = specHelper.newUser();
user.balance = 4, user.balance = 4,
user.items = {eggs: {Cactus: 1}, hatchingPotions: {Base: 1}, food: {Meat: 1}, pets: {}}; user.items = {eggs: {Cactus: 1}, hatchingPotions: {Base: 1}, food: {Meat: 1}, pets: {}, mounts: {}};
Shared.wrap(user); Shared.wrap(user);
var mockWindow = { var mockWindow = {
confirm: function(msg){ confirm: function(msg){
@@ -16,8 +19,13 @@ describe('Inventory Controller', function() {
} }
}; };
scope = $rootScope.$new(); scope = $rootScope.$new();
// Load RootCtrl to ensure shared behaviors are loaded
$controller('RootCtrl', {$scope: scope, User: {user: user}, $window: mockWindow});
ctrl = $controller('InventoryCtrl', {$scope: scope, User: {user: user}, $window: mockWindow}); ctrl = $controller('InventoryCtrl', {$scope: scope, User: {user: user}, $window: mockWindow});
})); });
});
it('starts without any item selected', function(){ it('starts without any item selected', function(){
expect(scope.selectedEgg).to.eql(null); expect(scope.selectedEgg).to.eql(null);
@@ -35,7 +43,7 @@ describe('Inventory Controller', function() {
expect(scope.selectedPotion.key).to.eql('Base'); expect(scope.selectedPotion.key).to.eql('Base');
}); });
xit('hatches a pet', function(){ it('hatches a pet', function(){
scope.chooseEgg('Cactus'); scope.chooseEgg('Cactus');
scope.choosePotion('Base'); scope.choosePotion('Base');
expect(user.items.eggs).to.eql({Cactus: 0}); expect(user.items.eggs).to.eql({Cactus: 0});

View File

@@ -1,17 +1,23 @@
'use strict'; 'use strict';
// @TODO: Something here is calling a full page reload // @TODO: Something here is calling a full page reload
xdescribe('Root Controller', function() { describe('Root Controller', function() {
var scope, user, ctrl; var scope, user, ctrl;
beforeEach(inject(function($rootScope, $controller) { beforeEach(function () {
module(function($provide) {
$provide.value('User', {});
});
inject(function($rootScope, $controller) {
scope = $rootScope.$new(); scope = $rootScope.$new();
scope.loginUsername = 'user' scope.loginUsername = 'user'
scope.loginPassword = 'pass' scope.loginPassword = 'pass'
user = specHelper.newUser(); user = specHelper.newUser();
ctrl = $controller('RootCtrl', {$scope: scope, User: {user: user}}); ctrl = $controller('RootCtrl', {$scope: scope, User: {user: user}});
})); });
});
it('shows contributor level text', function(){ it('shows contributor level text', function(){
expect(scope.contribText()).to.eql(undefined); expect(scope.contribText()).to.eql(undefined);