Kouhei Sutou
null+****@clear*****
Sun Jul 21 16:32:20 JST 2013
Kouhei Sutou 2013-07-21 16:32:20 +0900 (Sun, 21 Jul 2013) New Revision: 730594b5e5af5a99e7cb2636f8f36e72974cc84d https://github.com/groonga/express-droonga/commit/730594b5e5af5a99e7cb2636f8f36e72974cc84d Message: test: return response on receiving request instead of using wait() wait() makes test fragile. Modified files: test/frontend-rest-adaptor.test.js Modified: test/frontend-rest-adaptor.test.js (+17 -17) =================================================================== --- test/frontend-rest-adaptor.test.js 2013-07-21 14:56:47 +0900 (f5f44d4) +++ test/frontend-rest-adaptor.test.js 2013-07-21 16:32:20 +0900 (330bd87) @@ -107,28 +107,28 @@ suite('REST API', function() { plugins: [testPlugin] }); - var mockedReceiver = nodemock - .mock('receive') - .takes('api OK'); + backend.reserveResponse(function(request) { + var tag = request[0]; + var timestamp = 0; + var envelope = request[2]; + return [ + tag, + timestamp, + { + inReplyTo: envelope.id, + statusCode: 200, + body: 'API response' + } + ]; + }); utils.get('/path/to/api') .next(function(response) { - mockedReceiver.receive(response.body); - }); - - Deferred - .wait(0.01) - .next(function() { backend.assertReceived([{ type: 'api', body: 'api requested' }]); - - return backend.sendResponse(backend.getMessages()[0], - 'api.result', - 'api OK?'); - }) - .wait(0.01) - .next(function() { - mockedReceiver.assertThrows(); + assert.deepEqual({ statusCode: 200, + body: JSON.stringify('api OK') }, + response); done(); }) .error(function(error) { -------------- next part -------------- HTML����������������������������...Download