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

View File

@@ -1,17 +1,23 @@
'use strict';
// @TODO: Something here is calling a full page reload
xdescribe('Root Controller', function() {
describe('Root Controller', function() {
var scope, user, ctrl;
beforeEach(inject(function($rootScope, $controller) {
scope = $rootScope.$new();
scope.loginUsername = 'user'
scope.loginPassword = 'pass'
user = specHelper.newUser();
beforeEach(function () {
module(function($provide) {
$provide.value('User', {});
});
ctrl = $controller('RootCtrl', {$scope: scope, User: {user: user}});
}));
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);