{"action":"created","issue":{"url":"https://api.github.com/repos/howardabrams/node-mocks-http/issues/11","labels_url":"https://api.github.com/repos/howardabrams/node-mocks-http/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/howardabrams/node-mocks-http/issues/11/comments","events_url":"https://api.github.com/repos/howardabrams/node-mocks-http/issues/11/events","html_url":"https://github.com/howardabrams/node-mocks-http/pull/11","id":28570570,"number":11,"title":"Add end, send and render events for async testing.","user":{"login":"invernizzie","id":610970,"avatar_url":"https://avatars.githubusercontent.com/u/610970?v=3","gravatar_id":"","url":"https://api.github.com/users/invernizzie","html_url":"https://github.com/invernizzie","followers_url":"https://api.github.com/users/invernizzie/followers","following_url":"https://api.github.com/users/invernizzie/following{/other_user}","gists_url":"https://api.github.com/users/invernizzie/gists{/gist_id}","starred_url":"https://api.github.com/users/invernizzie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/invernizzie/subscriptions","organizations_url":"https://api.github.com/users/invernizzie/orgs","repos_url":"https://api.github.com/users/invernizzie/repos","events_url":"https://api.github.com/users/invernizzie/events{/privacy}","received_events_url":"https://api.github.com/users/invernizzie/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-03-02T01:28:31Z","updated_at":"2015-01-10T23:10:47Z","closed_at":"2014-03-30T22:34:48Z","pull_request":{"url":"https://api.github.com/repos/howardabrams/node-mocks-http/pulls/11","html_url":"https://github.com/howardabrams/node-mocks-http/pull/11","diff_url":"https://github.com/howardabrams/node-mocks-http/pull/11.diff","patch_url":"https://github.com/howardabrams/node-mocks-http/pull/11.patch"},"body":"This closes #6. We can write tests for asyncrhonous responses as shown below.\r\n\r\nCode under test:\r\n```javascript\r\nfunction myHandler(request, response) {\r\n  setTimeout(function() {\r\n    response.end();\r\n  }, 1000);\r\n}\r\n```\r\n\r\n```javascript\r\nexports['End is called'] = function (test) {\r\n  request = httpMocks.createRequest();\r\n  var response = httpMocks.createResponse({\r\n    eventEmitter: EventEmitter\r\n  });\r\n  \r\n  response.on('end', function () {\r\n    test.ok(response._isEndCalled());\r\n    test.done();\r\n  });\r\n\r\n  myHandler(request, response);\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/howardabrams/node-mocks-http/issues/comments/69476072","html_url":"https://github.com/howardabrams/node-mocks-http/pull/11#issuecomment-69476072","issue_url":"https://api.github.com/repos/howardabrams/node-mocks-http/issues/11","id":69476072,"user":{"login":"howardabrams","id":500621,"avatar_url":"https://avatars.githubusercontent.com/u/500621?v=3","gravatar_id":"","url":"https://api.github.com/users/howardabrams","html_url":"https://github.com/howardabrams","followers_url":"https://api.github.com/users/howardabrams/followers","following_url":"https://api.github.com/users/howardabrams/following{/other_user}","gists_url":"https://api.github.com/users/howardabrams/gists{/gist_id}","starred_url":"https://api.github.com/users/howardabrams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/howardabrams/subscriptions","organizations_url":"https://api.github.com/users/howardabrams/orgs","repos_url":"https://api.github.com/users/howardabrams/repos","events_url":"https://api.github.com/users/howardabrams/events{/privacy}","received_events_url":"https://api.github.com/users/howardabrams/received_events","type":"User","site_admin":false},"created_at":"2015-01-10T23:10:47Z","updated_at":"2015-01-10T23:10:47Z","body":"Would creating a mock version of EventEmitter be sufficient? Could you give me a test case you would like to see, and we can try to come up with something?"}}