{"action":"created","comment":{"url":"https://api.github.com/repos/Arodang/Moroja/pulls/comments/60572607","id":60572607,"diff_hunk":"@@ -62,104 +66,152 @@ describe('The VillageService\\'s', function() {\n \n         StorageService = {\n             saveVillage : sinon.stub().returns(true),\n-            getVillage: sinon.stub().returns(village)\n+            getVillage: sinon.stub().returns(village),\n+            resetVillage: sinon.stub().returns()\n         };\n \n         ConstantsService = {\n-            getResourceSchema : sinon.stub().returns(baseValues),\n+            getResourceSchema : sinon.stub().returns(resourceSchema),\n             getResources : sinon.stub().returns(village),\n             getBuildingSchema : sinon.stub().returns(buildingSchema)\n         };\n \n         TimeService = {\n-            getBasicTimer : sinon.stub().returns({}),\n+            getBasicTimer : sinon.stub().returns(true),\n             addTime : sinon.stub().returns({})\n         };\n \n-        VillageService = new VillageServiceModule(StorageService, ConstantsService, TimeService);\n+        $rootScope = {\n+            $broadcast: sinon.stub().returns({})\n+        };\n+\n+        VillageService = new VillageServiceModule(StorageService, ConstantsService, TimeService, $rootScope);\n     });\n \n     describe('addResource', function() {\n-        it('should return an increased amount of lumber when called for lumber', function() {\n-            var response = VillageService.addResource(\"lumber\", village);\n+        it('should increase the amount of lumber when called for lumber', function() {\n+            VillageService.addResource(\"lumber\");\n+            var vil = VillageService.getVillage();\n \n             expect(StorageService.saveVillage).to.have.been.called;\n-            expect(response.resources.lumber.amount).to.equal(8);\n+            expect(TimeService.addTime).to.have.been.called;\n+            expect($rootScope.$broadcast).to.have.been.called.twice;\n+            expect(vil.resources.lumber.amount).to.equal(8);\n         });\n \n         it('should increase firewood and decrease lumber when called for firewood', function() {\n-            var response = VillageService.addResource(\"firewood\", village);\n+            VillageService.addResource(\"firewood\", village);\n+            var vil = VillageService.getVillage();\n \n             expect(StorageService.saveVillage).to.have.been.called;\n-            expect(response.resources.lumber.amount).to.equal(4);\n-            expect(response.resources.firewood.amount).to.equal(10);\n+            expect(TimeService.addTime).to.have.been.called;\n+            expect($rootScope.$broadcast).to.have.been.called.twice;\n+            expect(vil.resources.lumber.amount).to.equal(4);\n+            expect(vil.resources.firewood.amount).to.equal(10);\n         });\n \n-        it('should return the original resources if StorageService.saveVillage returns false', function() {\n+        it('should not change resources if StorageService.saveVillage returns false', function() {\n             StorageService.saveVillage = sinon.stub().returns(false);\n+            var vil = VillageService.getVillage();\n \n-            var response = VillageService.addResource(\"lumber\", village);\n+            VillageService.addResource(\"lumber\", village);\n \n-            expect(StorageService.saveVillage).to.have.been.called;\n-            expect(response).to.equal(village);\n+            expect(TimeService.addTime).to.have.been.called;\n+            expect($rootScope.$broadcast).to.have.been.called.once;\n+            expect(StorageService.saveVillage).to.have.been.called.twice;\n+            expect(vil.resources.lumber.amount).to.equal(5);\n         });\n \n-        it('should return original resources if there are insufficient resources', function() {\n+        it('should not change resources if there are insufficient resources', function() {\n             StorageService.saveVillage = sinon.stub().returns(true);\n             village.resources.lumber.amount = 0;\n \n-            var response = VillageService.addResource(\"firewood\", village);\n+            VillageService.addResource(\"firewood\", village);\n+            var vil = VillageService.getVillage();\n \n+            expect(TimeService.addTime).not.to.have.been.called;\n+            expect($rootScope.$broadcast).to.have.been.called.once;\n             expect(StorageService.saveVillage).not.to.have.been.called;\n-            expect(response).to.equal(village);\n+            expect(vil.resources.lumber.amount).to.equal(0);\n         });\n \n         it('should apply the resource multiplier to lumber if the village has a Saw Mill', function() {\n             village.buildings[\"sawMill\"].level = 1;\n \n-            var response = VillageService.addResource(\"lumber\", village);\n+            VillageService.addResource(\"lumber\", village);\n+            var vil = VillageService.getVillage();\n \n             expect(StorageService.saveVillage).to.have.been.called;\n-            expect(response.resources.lumber.amount).to.equal(5 + 3*1.25);\n+            expect(TimeService.addTime).to.have.been.called;\n+            expect($rootScope.$broadcast).to.have.been.called.twice;\n+            expect(vil.resources.lumber.amount).to.equal(5 + 3*1.25);\n         });\n     });\n \n     describe('buyBuilding', function() {\n         it('should make the Saw Mill level 1 after buying that building', function () {\n-            var response = VillageService.buyBuilding(\"sawMill\", village);\n+            VillageService.buyBuilding(\"sawMill\", village);\n+            var vil = VillageService.getVillage();\n \n             expect(StorageService.saveVillage).to.have.been.called;\n-            expect(response.buildings[\"sawMill\"].level).to.equal(1);\n+            expect($rootScope.$broadcast).to.have.been.called.twice;\n+            expect(vil.buildings[\"sawMill\"].level).to.equal(1);\n         });\n \n         it('should not change the level of Saw Mill if StorageService.saveVillage fails', function () {\n             StorageService.saveVillage = sinon.stub().returns(false);\n \n-            var response = VillageService.buyBuilding(\"sawMill\", village);\n+            VillageService.buyBuilding(\"sawMill\", village);\n+            var vil = VillageService.getVillage();\n \n             expect(StorageService.saveVillage).to.have.been.called;\n-            expect(response.buildings[\"sawMill\"].level).to.equal(0);\n+            expect($rootScope.$broadcast).to.have.been.called.once;\n+            expect(vil.buildings[\"sawMill\"].level).to.equal(0);\n         });\n     });\n \n     describe('getVillage', function() {\n-        it('should get the village from StorageService.getVillage', function() {\n+        it('should return the village', function() {\n             var response = VillageService.getVillage();\n \n-            expect(StorageService.getVillage).to.have.been.called;\n-            expect(ConstantsService.getResources).not.to.have.been.calledAfter(StorageService.getVillage);\n             expect(response).to.equal(village);\n         });\n+    });\n \n-        it('should use the base resources if StorageService.getVillage returns null', function() {\n-            StorageService.getVillage = sinon.stub().returns(null);\n+    describe('createVillage', function() {\n+        it('should populate description, buildings, resources, and time', function() {\n+            VillageService.createVillage();\n+            var vil = VillageService.getVillage();\n+\n+            expect(vil.resources).to.equal(village);\n+            expect(vil.time).to.equal(true);\n+            expect(vil.buildings).to.not.be.null;\n+            expect(StorageService.saveVillage).to.have.been.called.twice;","path":"test/unit/village/services/villageService.js","position":197,"original_position":179,"commit_id":"a4416b108727f3ca5d6e0ba536b967b4f54552cb","original_commit_id":"a4416b108727f3ca5d6e0ba536b967b4f54552cb","user":{"login":"khipkin","id":5641207,"avatar_url":"https://avatars.githubusercontent.com/u/5641207?v=3","gravatar_id":"","url":"https://api.github.com/users/khipkin","html_url":"https://github.com/khipkin","followers_url":"https://api.github.com/users/khipkin/followers","following_url":"https://api.github.com/users/khipkin/following{/other_user}","gists_url":"https://api.github.com/users/khipkin/gists{/gist_id}","starred_url":"https://api.github.com/users/khipkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khipkin/subscriptions","organizations_url":"https://api.github.com/users/khipkin/orgs","repos_url":"https://api.github.com/users/khipkin/repos","events_url":"https://api.github.com/users/khipkin/events{/privacy}","received_events_url":"https://api.github.com/users/khipkin/received_events","type":"User","site_admin":false},"body":"Jk, as you pointed out the storage service is mocked.  Maybe grab the param(s) to the last save call? And make sure it has all updated village values we expect.\r\n","created_at":"2016-04-21T12:43:17Z","updated_at":"2016-04-21T12:43:17Z","html_url":"https://github.com/Arodang/Moroja/pull/9#discussion_r60572607","pull_request_url":"https://api.github.com/repos/Arodang/Moroja/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/Arodang/Moroja/pulls/comments/60572607"},"html":{"href":"https://github.com/Arodang/Moroja/pull/9#discussion_r60572607"},"pull_request":{"href":"https://api.github.com/repos/Arodang/Moroja/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/Arodang/Moroja/pulls/9","id":65911358,"html_url":"https://github.com/Arodang/Moroja/pull/9","diff_url":"https://github.com/Arodang/Moroja/pull/9.diff","patch_url":"https://github.com/Arodang/Moroja/pull/9.patch","issue_url":"https://api.github.com/repos/Arodang/Moroja/issues/9","number":9,"state":"open","locked":false,"title":"Refactor Project","user":{"login":"Arodang","id":1715040,"avatar_url":"https://avatars.githubusercontent.com/u/1715040?v=3","gravatar_id":"","url":"https://api.github.com/users/Arodang","html_url":"https://github.com/Arodang","followers_url":"https://api.github.com/users/Arodang/followers","following_url":"https://api.github.com/users/Arodang/following{/other_user}","gists_url":"https://api.github.com/users/Arodang/gists{/gist_id}","starred_url":"https://api.github.com/users/Arodang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Arodang/subscriptions","organizations_url":"https://api.github.com/users/Arodang/orgs","repos_url":"https://api.github.com/users/Arodang/repos","events_url":"https://api.github.com/users/Arodang/events{/privacy}","received_events_url":"https://api.github.com/users/Arodang/received_events","type":"User","site_admin":false},"body":"Ignore the fact that the branch is called browserifyCSS...\r\n-Removed JS folder and bumped modules up a level\r\n-Refactored \"components\" and \"structure\" into \"shared\" module with \"partials\" and \"services\" as subfolders\r\n","created_at":"2016-04-10T14:05:32Z","updated_at":"2016-04-21T12:43:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2d9663a5cb91a1df4a9172af469e093604d3ab60","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Arodang/Moroja/pulls/9/commits","review_comments_url":"https://api.github.com/repos/Arodang/Moroja/pulls/9/comments","review_comment_url":"https://api.github.com/repos/Arodang/Moroja/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Arodang/Moroja/issues/9/comments","statuses_url":"https://api.github.com/repos/Arodang/Moroja/statuses/a4416b108727f3ca5d6e0ba536b967b4f54552cb","head":{"label":"Arodang:browserifyCSS","ref":"browserifyCSS","sha":"a4416b108727f3ca5d6e0ba536b967b4f54552cb","user":{"login":"Arodang","id":1715040,"avatar_url":"https://avatars.githubusercontent.com/u/1715040?v=3","gravatar_id":"","url":"https://api.github.com/users/Arodang","html_url":"https://github.com/Arodang","followers_url":"https://api.github.com/users/Arodang/followers","following_url":"https://api.github.com/users/Arodang/following{/other_user}","gists_url":"https://api.github.com/users/Arodang/gists{/gist_id}","starred_url":"https://api.github.com/users/Arodang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Arodang/subscriptions","organizations_url":"https://api.github.com/users/Arodang/orgs","repos_url":"https://api.github.com/users/Arodang/repos","events_url":"https://api.github.com/users/Arodang/events{/privacy}","received_events_url":"https://api.github.com/users/Arodang/received_events","type":"User","site_admin":false},"repo":{"id":51778663,"name":"Moroja","full_name":"Arodang/Moroja","owner":{"login":"Arodang","id":1715040,"avatar_url":"https://avatars.githubusercontent.com/u/1715040?v=3","gravatar_id":"","url":"https://api.github.com/users/Arodang","html_url":"https://github.com/Arodang","followers_url":"https://api.github.com/users/Arodang/followers","following_url":"https://api.github.com/users/Arodang/following{/other_user}","gists_url":"https://api.github.com/users/Arodang/gists{/gist_id}","starred_url":"https://api.github.com/users/Arodang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Arodang/subscriptions","organizations_url":"https://api.github.com/users/Arodang/orgs","repos_url":"https://api.github.com/users/Arodang/repos","events_url":"https://api.github.com/users/Arodang/events{/privacy}","received_events_url":"https://api.github.com/users/Arodang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Arodang/Moroja","description":"","fork":false,"url":"https://api.github.com/repos/Arodang/Moroja","forks_url":"https://api.github.com/repos/Arodang/Moroja/forks","keys_url":"https://api.github.com/repos/Arodang/Moroja/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Arodang/Moroja/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Arodang/Moroja/teams","hooks_url":"https://api.github.com/repos/Arodang/Moroja/hooks","issue_events_url":"https://api.github.com/repos/Arodang/Moroja/issues/events{/number}","events_url":"https://api.github.com/repos/Arodang/Moroja/events","assignees_url":"https://api.github.com/repos/Arodang/Moroja/assignees{/user}","branches_url":"https://api.github.com/repos/Arodang/Moroja/branches{/branch}","tags_url":"https://api.github.com/repos/Arodang/Moroja/tags","blobs_url":"https://api.github.com/repos/Arodang/Moroja/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Arodang/Moroja/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Arodang/Moroja/git/refs{/sha}","trees_url":"https://api.github.com/repos/Arodang/Moroja/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Arodang/Moroja/statuses/{sha}","languages_url":"https://api.github.com/repos/Arodang/Moroja/languages","stargazers_url":"https://api.github.com/repos/Arodang/Moroja/stargazers","contributors_url":"https://api.github.com/repos/Arodang/Moroja/contributors","subscribers_url":"https://api.github.com/repos/Arodang/Moroja/subscribers","subscription_url":"https://api.github.com/repos/Arodang/Moroja/subscription","commits_url":"https://api.github.com/repos/Arodang/Moroja/commits{/sha}","git_commits_url":"https://api.github.com/repos/Arodang/Moroja/git/commits{/sha}","comments_url":"https://api.github.com/repos/Arodang/Moroja/comments{/number}","issue_comment_url":"https://api.github.com/repos/Arodang/Moroja/issues/comments{/number}","contents_url":"https://api.github.com/repos/Arodang/Moroja/contents/{+path}","compare_url":"https://api.github.com/repos/Arodang/Moroja/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Arodang/Moroja/merges","archive_url":"https://api.github.com/repos/Arodang/Moroja/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Arodang/Moroja/downloads","issues_url":"https://api.github.com/repos/Arodang/Moroja/issues{/number}","pulls_url":"https://api.github.com/repos/Arodang/Moroja/pulls{/number}","milestones_url":"https://api.github.com/repos/Arodang/Moroja/milestones{/number}","notifications_url":"https://api.github.com/repos/Arodang/Moroja/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Arodang/Moroja/labels{/name}","releases_url":"https://api.github.com/repos/Arodang/Moroja/releases{/id}","deployments_url":"https://api.github.com/repos/Arodang/Moroja/deployments","created_at":"2016-02-15T19:10:47Z","updated_at":"2016-02-28T21:05:28Z","pushed_at":"2016-04-17T21:38:54Z","git_url":"git://github.com/Arodang/Moroja.git","ssh_url":"git@github.com:Arodang/Moroja.git","clone_url":"https://github.com/Arodang/Moroja.git","svn_url":"https://github.com/Arodang/Moroja","homepage":null,"size":1110,"stargazers_count":2,"watchers_count":2,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"dev"}},"base":{"label":"Arodang:dev","ref":"dev","sha":"6eb34a054d39c2f3b750453d9772fa55e086ee5a","user":{"login":"Arodang","id":1715040,"avatar_url":"https://avatars.githubusercontent.com/u/1715040?v=3","gravatar_id":"","url":"https://api.github.com/users/Arodang","html_url":"https://github.com/Arodang","followers_url":"https://api.github.com/users/Arodang/followers","following_url":"https://api.github.com/users/Arodang/following{/other_user}","gists_url":"https://api.github.com/users/Arodang/gists{/gist_id}","starred_url":"https://api.github.com/users/Arodang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Arodang/subscriptions","organizations_url":"https://api.github.com/users/Arodang/orgs","repos_url":"https://api.github.com/users/Arodang/repos","events_url":"https://api.github.com/users/Arodang/events{/privacy}","received_events_url":"https://api.github.com/users/Arodang/received_events","type":"User","site_admin":false},"repo":{"id":51778663,"name":"Moroja","full_name":"Arodang/Moroja","owner":{"login":"Arodang","id":1715040,"avatar_url":"https://avatars.githubusercontent.com/u/1715040?v=3","gravatar_id":"","url":"https://api.github.com/users/Arodang","html_url":"https://github.com/Arodang","followers_url":"https://api.github.com/users/Arodang/followers","following_url":"https://api.github.com/users/Arodang/following{/other_user}","gists_url":"https://api.github.com/users/Arodang/gists{/gist_id}","starred_url":"https://api.github.com/users/Arodang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Arodang/subscriptions","organizations_url":"https://api.github.com/users/Arodang/orgs","repos_url":"https://api.github.com/users/Arodang/repos","events_url":"https://api.github.com/users/Arodang/events{/privacy}","received_events_url":"https://api.github.com/users/Arodang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Arodang/Moroja","description":"","fork":false,"url":"https://api.github.com/repos/Arodang/Moroja","forks_url":"https://api.github.com/repos/Arodang/Moroja/forks","keys_url":"https://api.github.com/repos/Arodang/Moroja/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Arodang/Moroja/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Arodang/Moroja/teams","hooks_url":"https://api.github.com/repos/Arodang/Moroja/hooks","issue_events_url":"https://api.github.com/repos/Arodang/Moroja/issues/events{/number}","events_url":"https://api.github.com/repos/Arodang/Moroja/events","assignees_url":"https://api.github.com/repos/Arodang/Moroja/assignees{/user}","branches_url":"https://api.github.com/repos/Arodang/Moroja/branches{/branch}","tags_url":"https://api.github.com/repos/Arodang/Moroja/tags","blobs_url":"https://api.github.com/repos/Arodang/Moroja/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Arodang/Moroja/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Arodang/Moroja/git/refs{/sha}","trees_url":"https://api.github.com/repos/Arodang/Moroja/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Arodang/Moroja/statuses/{sha}","languages_url":"https://api.github.com/repos/Arodang/Moroja/languages","stargazers_url":"https://api.github.com/repos/Arodang/Moroja/stargazers","contributors_url":"https://api.github.com/repos/Arodang/Moroja/contributors","subscribers_url":"https://api.github.com/repos/Arodang/Moroja/subscribers","subscription_url":"https://api.github.com/repos/Arodang/Moroja/subscription","commits_url":"https://api.github.com/repos/Arodang/Moroja/commits{/sha}","git_commits_url":"https://api.github.com/repos/Arodang/Moroja/git/commits{/sha}","comments_url":"https://api.github.com/repos/Arodang/Moroja/comments{/number}","issue_comment_url":"https://api.github.com/repos/Arodang/Moroja/issues/comments{/number}","contents_url":"https://api.github.com/repos/Arodang/Moroja/contents/{+path}","compare_url":"https://api.github.com/repos/Arodang/Moroja/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Arodang/Moroja/merges","archive_url":"https://api.github.com/repos/Arodang/Moroja/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Arodang/Moroja/downloads","issues_url":"https://api.github.com/repos/Arodang/Moroja/issues{/number}","pulls_url":"https://api.github.com/repos/Arodang/Moroja/pulls{/number}","milestones_url":"https://api.github.com/repos/Arodang/Moroja/milestones{/number}","notifications_url":"https://api.github.com/repos/Arodang/Moroja/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Arodang/Moroja/labels{/name}","releases_url":"https://api.github.com/repos/Arodang/Moroja/releases{/id}","deployments_url":"https://api.github.com/repos/Arodang/Moroja/deployments","created_at":"2016-02-15T19:10:47Z","updated_at":"2016-02-28T21:05:28Z","pushed_at":"2016-04-17T21:38:54Z","git_url":"git://github.com/Arodang/Moroja.git","ssh_url":"git@github.com:Arodang/Moroja.git","clone_url":"https://github.com/Arodang/Moroja.git","svn_url":"https://github.com/Arodang/Moroja","homepage":null,"size":1110,"stargazers_count":2,"watchers_count":2,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/Arodang/Moroja/pulls/9"},"html":{"href":"https://github.com/Arodang/Moroja/pull/9"},"issue":{"href":"https://api.github.com/repos/Arodang/Moroja/issues/9"},"comments":{"href":"https://api.github.com/repos/Arodang/Moroja/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/Arodang/Moroja/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/Arodang/Moroja/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Arodang/Moroja/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/Arodang/Moroja/statuses/a4416b108727f3ca5d6e0ba536b967b4f54552cb"}}}}