From 4777a693bacadb0f0f6a9b3fa940e09c4dd44354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Jureti=C4=87?= Date: Sat, 4 Jan 2014 17:35:45 -0300 Subject: [PATCH] Test refactoring: user.user -> user --- test/spec/inventoryCtrlSpec.js | 38 ++++++++++++++++------------------ 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/test/spec/inventoryCtrlSpec.js b/test/spec/inventoryCtrlSpec.js index 1e986dbd4e..9cbf9334ff 100644 --- a/test/spec/inventoryCtrlSpec.js +++ b/test/spec/inventoryCtrlSpec.js @@ -6,13 +6,11 @@ describe('Inventory Controller', function() { beforeEach(module('habitrpg')); beforeEach(inject(function($rootScope, $controller){ user = { - user: { - balance: 4, - stats: {gp: 0}, - items: {eggs: {Cactus: 1}, hatchingPotions: {Base: 1}, food: {Meat: 1}, pets: {}}, - } + balance: 4, + stats: {gp: 0}, + items: {eggs: {Cactus: 1}, hatchingPotions: {Base: 1}, food: {Meat: 1}, pets: {}}, }; - window.habitrpgShared.wrap(user.user); + window.habitrpgShared.wrap(user); var mockWindow = { confirm: function(msg){ return true; @@ -20,7 +18,7 @@ describe('Inventory Controller', function() { }; scope = $rootScope.$new(); $rootScope.Content = window.habitrpgShared.content; - ctrl = $controller('InventoryCtrl', {$scope: scope, User: user, $window: mockWindow}); + ctrl = $controller('InventoryCtrl', {$scope: scope, User: {user: user}, $window: mockWindow}); })); it('starts without any item selected', function(){ @@ -42,9 +40,9 @@ describe('Inventory Controller', function() { it('hatches a pet', function(){ scope.chooseEgg('Cactus'); scope.choosePotion('Base'); - expect(user.user.items.eggs).to.eql({Cactus: 0}); - expect(user.user.items.hatchingPotions).to.eql({Base: 0}); - expect(user.user.items.pets).to.eql({'Cactus-Base': 5}); + expect(user.items.eggs).to.eql({Cactus: 0}); + expect(user.items.hatchingPotions).to.eql({Base: 0}); + expect(user.items.pets).to.eql({'Cactus-Base': 5}); expect(scope.selectedEgg).to.eql(null); expect(scope.selectedPotion).to.eql(null); }); @@ -52,33 +50,33 @@ describe('Inventory Controller', function() { it('sells an egg', function(){ scope.chooseEgg('Cactus'); scope.sellInventory(); - expect(user.user.items.eggs).to.eql({Cactus: 0}); - expect(user.user.stats.gp).to.eql(3); + expect(user.items.eggs).to.eql({Cactus: 0}); + expect(user.stats.gp).to.eql(3); }); it('sells a potion', function(){ scope.choosePotion('Base'); scope.sellInventory(); - expect(user.user.items.hatchingPotions).to.eql({Base: 0}); - expect(user.user.stats.gp).to.eql(2); + expect(user.items.hatchingPotions).to.eql({Base: 0}); + expect(user.stats.gp).to.eql(2); }); it('sells food', function(){ scope.chooseFood('Meat'); scope.sellInventory(); - expect(user.user.items.food).to.eql({Meat: 0}); - expect(user.user.stats.gp).to.eql(1); + expect(user.items.food).to.eql({Meat: 0}); + expect(user.stats.gp).to.eql(1); }); it('chooses a pet', function(){ - user.user.items.pets['Cactus-Base'] = 5; + user.items.pets['Cactus-Base'] = 5; scope.choosePet('Cactus', 'Base'); - expect(user.user.items.currentPet).to.eql('Cactus-Base'); + expect(user.items.currentPet).to.eql('Cactus-Base'); }); it('purchases an egg', function(){ scope.purchase('eggs', window.habitrpgShared.content.eggs['Wolf']); - expect(user.user.balance).to.eql(3.25); - expect(user.user.items.eggs).to.eql({Cactus: 1, Wolf: 1}) + expect(user.balance).to.eql(3.25); + expect(user.items.eggs).to.eql({Cactus: 1, Wolf: 1}) }); });