Kouhei Sutou
null+****@clear*****
Sun Jul 21 17:58:28 JST 2013
Kouhei Sutou 2013-07-21 17:58:28 +0900 (Sun, 21 Jul 2013) New Revision: d73a63cbcb6e635a12aa427d753815fc389298a4 https://github.com/groonga/express-droonga/commit/d73a63cbcb6e635a12aa427d753815fc389298a4 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 (+10 -17) =================================================================== --- test/frontend/rest-adaptor.test.js 2013-07-21 17:55:22 +0900 (d035fd2) +++ test/frontend/rest-adaptor.test.js 2013-07-21 17:58:28 +0900 (4b1c6b8) @@ -136,28 +136,21 @@ suite('REST API', function() { plugins: [testPlugin] }); - var mockedReceiver = nodemock - .mock('receive') - .takes('api OK'); + backend.reserveResponse(function(request) { + return utils.createReplyPacket(request, + { + statusCode: 200, + body: 'API response', + }); + }); utils.get('/path/to/droonga/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(response, + { statusCode: 200, + body: JSON.stringify('api OK') }); done(); }) .error(function(error) { -------------- next part -------------- HTML����������������������������...Download