{"action":"created","comment":{"url":"https://api.github.com/repos/kjirou/downspout/pulls/comments/90362729","pull_request_review_id":10882677,"id":90362729,"diff_hunk":"@@ -0,0 +1,293 @@\n+const assert = require('assert');\n+const sinon = require('sinon');\n+\n+const Downspout = require('../../lib/Downspout');\n+\n+\n+describe('lib/Downspout', () => {\n+  beforeEach(() => {\n+    sinon.stub(Downspout, '_getDefaultIsNoisy', () => true);\n+  });\n+\n+  afterEach(() => {\n+    Downspout._getDefaultIsNoisy.restore();\n+  });\n+\n+  describe('constructor', () => {\n+    it('should be created by only use-case logics', () => {\n+      const downspout = new Downspout({\n+        createFoo: () => {},\n+      });\n+      assert.strictEqual(downspout instanceof Downspout, true);\n+    });\n+  });\n+\n+  describe('Emitting events by use-case executions', () => {\n+    it('should emit a \"resolved\" event after an use-case execution', done => {\n+      const downspout = new Downspout({\n+        createFoo: () => 'FOO',\n+      });\n+      downspout.on('execution:resolved', ({ result }) => {\n+        assert.strictEqual(result, 'FOO');\n+        done();\n+      });\n+      downspout.execute('createFoo');\n+    });\n+\n+    it('should emit some \"execution:resolved\" events after some use-case executions', done => {\n+      let counter = 0;\n+      const downspout = new Downspout({\n+        count: () => counter += 1,\n+      });\n+\n+      const results = [];\n+      downspout.on('execution:resolved', ({ result }) => {\n+        results.push(result);\n+        if (results.length === 3) {\n+          assert.deepStrictEqual([1, 2, 3], results);\n+          done();\n+        }\n+      });\n+\n+      downspout.execute('count');\n+      downspout.execute('count');\n+      downspout.execute('count');\n+    });\n+\n+    it('should emit a \"rejected\" event after an use-case execution failure', done => {\n+      const downspout = new Downspout({\n+        createFoo: () => { throw new Error('FOO?'); },\n+      }, { isNoisy: false });\n+      downspout.on('execution:rejected', ({ error }) => {\n+        assert.strictEqual(error.message, 'FOO?');\n+        done();\n+      });\n+      downspout.execute('createFoo');\n+    });\n+\n+    it('should not execute use-cases after an use-case execution failure', done => {\n+      let results = [];\n+      const downspout = new Downspout({\n+        ng: () => { throw new Error('NG'); },\n+        ok: () => 'OK',\n+      }, { isNoisy: false });\n+      downspout.on('execution:rejected', ({ error }) => {\n+        results.push(error.message);\n+      });\n+      downspout.on('execution:resolved', ({ result }) => {\n+        results.push(result);\n+      });\n+\n+      downspout.execute('ng');\n+      downspout.execute('ok');\n+\n+      setTimeout(() => {","path":"test/lib/Downspout.js","position":84,"original_position":84,"commit_id":"85ee442a702e200facee63a054d70b6f35334f44","original_commit_id":"8a9bec8913f591c653d1b0e1eb01adafedb8c4c8","user":{"login":"OsugaHiroshi","id":21378304,"avatar_url":"https://avatars.githubusercontent.com/u/21378304?v=3","gravatar_id":"","url":"https://api.github.com/users/OsugaHiroshi","html_url":"https://github.com/OsugaHiroshi","followers_url":"https://api.github.com/users/OsugaHiroshi/followers","following_url":"https://api.github.com/users/OsugaHiroshi/following{/other_user}","gists_url":"https://api.github.com/users/OsugaHiroshi/gists{/gist_id}","starred_url":"https://api.github.com/users/OsugaHiroshi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OsugaHiroshi/subscriptions","organizations_url":"https://api.github.com/users/OsugaHiroshi/orgs","repos_url":"https://api.github.com/users/OsugaHiroshi/repos","events_url":"https://api.github.com/users/OsugaHiroshi/events{/privacy}","received_events_url":"https://api.github.com/users/OsugaHiroshi/received_events","type":"User","site_admin":false},"body":"ここ待たなくてもassertできそうなのに setTimeoutあるのなんでだろう？\r\n\r\nってとこが疑問のスタート地点でした。","created_at":"2016-12-01T00:48:02Z","updated_at":"2016-12-01T00:48:02Z","html_url":"https://github.com/kjirou/downspout/pull/9#discussion_r90362729","pull_request_url":"https://api.github.com/repos/kjirou/downspout/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/kjirou/downspout/pulls/comments/90362729"},"html":{"href":"https://github.com/kjirou/downspout/pull/9#discussion_r90362729"},"pull_request":{"href":"https://api.github.com/repos/kjirou/downspout/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/kjirou/downspout/pulls/9","id":95873878,"html_url":"https://github.com/kjirou/downspout/pull/9","diff_url":"https://github.com/kjirou/downspout/pull/9.diff","patch_url":"https://github.com/kjirou/downspout/pull/9.patch","issue_url":"https://api.github.com/repos/kjirou/downspout/issues/9","number":9,"state":"open","locked":false,"title":"事後レビュー用プルリクエスト","user":{"login":"kjirou","id":648041,"avatar_url":"https://avatars.githubusercontent.com/u/648041?v=3","gravatar_id":"","url":"https://api.github.com/users/kjirou","html_url":"https://github.com/kjirou","followers_url":"https://api.github.com/users/kjirou/followers","following_url":"https://api.github.com/users/kjirou/following{/other_user}","gists_url":"https://api.github.com/users/kjirou/gists{/gist_id}","starred_url":"https://api.github.com/users/kjirou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjirou/subscriptions","organizations_url":"https://api.github.com/users/kjirou/orgs","repos_url":"https://api.github.com/users/kjirou/repos","events_url":"https://api.github.com/users/kjirou/events{/privacy}","received_events_url":"https://api.github.com/users/kjirou/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-30T11:28:41Z","updated_at":"2016-12-01T00:48:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3c59dda829432e5d0567cb811eabcfa309a07274","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/kjirou/downspout/pulls/9/commits","review_comments_url":"https://api.github.com/repos/kjirou/downspout/pulls/9/comments","review_comment_url":"https://api.github.com/repos/kjirou/downspout/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kjirou/downspout/issues/9/comments","statuses_url":"https://api.github.com/repos/kjirou/downspout/statuses/85ee442a702e200facee63a054d70b6f35334f44","head":{"label":"kjirou:master","ref":"master","sha":"85ee442a702e200facee63a054d70b6f35334f44","user":{"login":"kjirou","id":648041,"avatar_url":"https://avatars.githubusercontent.com/u/648041?v=3","gravatar_id":"","url":"https://api.github.com/users/kjirou","html_url":"https://github.com/kjirou","followers_url":"https://api.github.com/users/kjirou/followers","following_url":"https://api.github.com/users/kjirou/following{/other_user}","gists_url":"https://api.github.com/users/kjirou/gists{/gist_id}","starred_url":"https://api.github.com/users/kjirou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjirou/subscriptions","organizations_url":"https://api.github.com/users/kjirou/orgs","repos_url":"https://api.github.com/users/kjirou/repos","events_url":"https://api.github.com/users/kjirou/events{/privacy}","received_events_url":"https://api.github.com/users/kjirou/received_events","type":"User","site_admin":false},"repo":{"id":73939060,"name":"downspout","full_name":"kjirou/downspout","owner":{"login":"kjirou","id":648041,"avatar_url":"https://avatars.githubusercontent.com/u/648041?v=3","gravatar_id":"","url":"https://api.github.com/users/kjirou","html_url":"https://github.com/kjirou","followers_url":"https://api.github.com/users/kjirou/followers","following_url":"https://api.github.com/users/kjirou/following{/other_user}","gists_url":"https://api.github.com/users/kjirou/gists{/gist_id}","starred_url":"https://api.github.com/users/kjirou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjirou/subscriptions","organizations_url":"https://api.github.com/users/kjirou/orgs","repos_url":"https://api.github.com/users/kjirou/repos","events_url":"https://api.github.com/users/kjirou/events{/privacy}","received_events_url":"https://api.github.com/users/kjirou/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kjirou/downspout","description":"Queue the emitting of disorderly events and write business logics routinely","fork":false,"url":"https://api.github.com/repos/kjirou/downspout","forks_url":"https://api.github.com/repos/kjirou/downspout/forks","keys_url":"https://api.github.com/repos/kjirou/downspout/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kjirou/downspout/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kjirou/downspout/teams","hooks_url":"https://api.github.com/repos/kjirou/downspout/hooks","issue_events_url":"https://api.github.com/repos/kjirou/downspout/issues/events{/number}","events_url":"https://api.github.com/repos/kjirou/downspout/events","assignees_url":"https://api.github.com/repos/kjirou/downspout/assignees{/user}","branches_url":"https://api.github.com/repos/kjirou/downspout/branches{/branch}","tags_url":"https://api.github.com/repos/kjirou/downspout/tags","blobs_url":"https://api.github.com/repos/kjirou/downspout/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kjirou/downspout/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kjirou/downspout/git/refs{/sha}","trees_url":"https://api.github.com/repos/kjirou/downspout/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kjirou/downspout/statuses/{sha}","languages_url":"https://api.github.com/repos/kjirou/downspout/languages","stargazers_url":"https://api.github.com/repos/kjirou/downspout/stargazers","contributors_url":"https://api.github.com/repos/kjirou/downspout/contributors","subscribers_url":"https://api.github.com/repos/kjirou/downspout/subscribers","subscription_url":"https://api.github.com/repos/kjirou/downspout/subscription","commits_url":"https://api.github.com/repos/kjirou/downspout/commits{/sha}","git_commits_url":"https://api.github.com/repos/kjirou/downspout/git/commits{/sha}","comments_url":"https://api.github.com/repos/kjirou/downspout/comments{/number}","issue_comment_url":"https://api.github.com/repos/kjirou/downspout/issues/comments{/number}","contents_url":"https://api.github.com/repos/kjirou/downspout/contents/{+path}","compare_url":"https://api.github.com/repos/kjirou/downspout/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kjirou/downspout/merges","archive_url":"https://api.github.com/repos/kjirou/downspout/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kjirou/downspout/downloads","issues_url":"https://api.github.com/repos/kjirou/downspout/issues{/number}","pulls_url":"https://api.github.com/repos/kjirou/downspout/pulls{/number}","milestones_url":"https://api.github.com/repos/kjirou/downspout/milestones{/number}","notifications_url":"https://api.github.com/repos/kjirou/downspout/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kjirou/downspout/labels{/name}","releases_url":"https://api.github.com/repos/kjirou/downspout/releases{/id}","deployments_url":"https://api.github.com/repos/kjirou/downspout/deployments","created_at":"2016-11-16T16:30:53Z","updated_at":"2016-11-30T12:40:09Z","pushed_at":"2016-11-30T17:52:00Z","git_url":"git://github.com/kjirou/downspout.git","ssh_url":"git@github.com:kjirou/downspout.git","clone_url":"https://github.com/kjirou/downspout.git","svn_url":"https://github.com/kjirou/downspout","homepage":"","size":483,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"kjirou:empty-for-pr","ref":"empty-for-pr","sha":"cd98f6fd72d4594ac28325e0d9ab34407fdd3260","user":{"login":"kjirou","id":648041,"avatar_url":"https://avatars.githubusercontent.com/u/648041?v=3","gravatar_id":"","url":"https://api.github.com/users/kjirou","html_url":"https://github.com/kjirou","followers_url":"https://api.github.com/users/kjirou/followers","following_url":"https://api.github.com/users/kjirou/following{/other_user}","gists_url":"https://api.github.com/users/kjirou/gists{/gist_id}","starred_url":"https://api.github.com/users/kjirou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjirou/subscriptions","organizations_url":"https://api.github.com/users/kjirou/orgs","repos_url":"https://api.github.com/users/kjirou/repos","events_url":"https://api.github.com/users/kjirou/events{/privacy}","received_events_url":"https://api.github.com/users/kjirou/received_events","type":"User","site_admin":false},"repo":{"id":73939060,"name":"downspout","full_name":"kjirou/downspout","owner":{"login":"kjirou","id":648041,"avatar_url":"https://avatars.githubusercontent.com/u/648041?v=3","gravatar_id":"","url":"https://api.github.com/users/kjirou","html_url":"https://github.com/kjirou","followers_url":"https://api.github.com/users/kjirou/followers","following_url":"https://api.github.com/users/kjirou/following{/other_user}","gists_url":"https://api.github.com/users/kjirou/gists{/gist_id}","starred_url":"https://api.github.com/users/kjirou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjirou/subscriptions","organizations_url":"https://api.github.com/users/kjirou/orgs","repos_url":"https://api.github.com/users/kjirou/repos","events_url":"https://api.github.com/users/kjirou/events{/privacy}","received_events_url":"https://api.github.com/users/kjirou/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kjirou/downspout","description":"Queue the emitting of disorderly events and write business logics routinely","fork":false,"url":"https://api.github.com/repos/kjirou/downspout","forks_url":"https://api.github.com/repos/kjirou/downspout/forks","keys_url":"https://api.github.com/repos/kjirou/downspout/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kjirou/downspout/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kjirou/downspout/teams","hooks_url":"https://api.github.com/repos/kjirou/downspout/hooks","issue_events_url":"https://api.github.com/repos/kjirou/downspout/issues/events{/number}","events_url":"https://api.github.com/repos/kjirou/downspout/events","assignees_url":"https://api.github.com/repos/kjirou/downspout/assignees{/user}","branches_url":"https://api.github.com/repos/kjirou/downspout/branches{/branch}","tags_url":"https://api.github.com/repos/kjirou/downspout/tags","blobs_url":"https://api.github.com/repos/kjirou/downspout/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kjirou/downspout/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kjirou/downspout/git/refs{/sha}","trees_url":"https://api.github.com/repos/kjirou/downspout/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kjirou/downspout/statuses/{sha}","languages_url":"https://api.github.com/repos/kjirou/downspout/languages","stargazers_url":"https://api.github.com/repos/kjirou/downspout/stargazers","contributors_url":"https://api.github.com/repos/kjirou/downspout/contributors","subscribers_url":"https://api.github.com/repos/kjirou/downspout/subscribers","subscription_url":"https://api.github.com/repos/kjirou/downspout/subscription","commits_url":"https://api.github.com/repos/kjirou/downspout/commits{/sha}","git_commits_url":"https://api.github.com/repos/kjirou/downspout/git/commits{/sha}","comments_url":"https://api.github.com/repos/kjirou/downspout/comments{/number}","issue_comment_url":"https://api.github.com/repos/kjirou/downspout/issues/comments{/number}","contents_url":"https://api.github.com/repos/kjirou/downspout/contents/{+path}","compare_url":"https://api.github.com/repos/kjirou/downspout/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kjirou/downspout/merges","archive_url":"https://api.github.com/repos/kjirou/downspout/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kjirou/downspout/downloads","issues_url":"https://api.github.com/repos/kjirou/downspout/issues{/number}","pulls_url":"https://api.github.com/repos/kjirou/downspout/pulls{/number}","milestones_url":"https://api.github.com/repos/kjirou/downspout/milestones{/number}","notifications_url":"https://api.github.com/repos/kjirou/downspout/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kjirou/downspout/labels{/name}","releases_url":"https://api.github.com/repos/kjirou/downspout/releases{/id}","deployments_url":"https://api.github.com/repos/kjirou/downspout/deployments","created_at":"2016-11-16T16:30:53Z","updated_at":"2016-11-30T12:40:09Z","pushed_at":"2016-11-30T17:52:00Z","git_url":"git://github.com/kjirou/downspout.git","ssh_url":"git@github.com:kjirou/downspout.git","clone_url":"https://github.com/kjirou/downspout.git","svn_url":"https://github.com/kjirou/downspout","homepage":"","size":483,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kjirou/downspout/pulls/9"},"html":{"href":"https://github.com/kjirou/downspout/pull/9"},"issue":{"href":"https://api.github.com/repos/kjirou/downspout/issues/9"},"comments":{"href":"https://api.github.com/repos/kjirou/downspout/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/kjirou/downspout/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/kjirou/downspout/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kjirou/downspout/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/kjirou/downspout/statuses/85ee442a702e200facee63a054d70b6f35334f44"}}}}
{"actor":{"display_login":"OsugaHiroshi"}}