YUKI Hiroshi
null+****@clear*****
Fri Oct 17 21:20:10 JST 2014
YUKI Hiroshi 2014-10-17 21:20:10 +0900 (Fri, 17 Oct 2014) New Revision: c0f1c75a3e59060a39574adc9a2ac81503f91063 https://github.com/droonga/express-droonga/commit/c0f1c75a3e59060a39574adc9a2ac81503f91063 Message: Simplify tests for socket.io adapter Modified files: test/express-adapter.test.js Modified: test/express-adapter.test.js (+12 -18) =================================================================== --- test/express-adapter.test.js 2014-10-17 21:18:17 +0900 (12e31c1) +++ test/express-adapter.test.js 2014-10-17 21:20:10 +0900 (d508d5a) @@ -115,7 +115,7 @@ suite('Adaption for express application', function() { var application; var connectionPool; var server; - var clientSocket; + var clients; setup(function(done) { connectionPool = utils.createStubbedBackendConnectionPool(); @@ -129,9 +129,11 @@ suite('Adaption for express application', function() { }); teardown(function() { - if (clientSocket) { - clientSocket.disconnect(); - clientSocket = undefined; + if (clients) { + clients.forEach(function(client) { + client.socket.disconnect(); + }); + clients = undefined; } utils.teardownApplication({ server: server, connectionPool: connectionPool }); @@ -145,23 +147,15 @@ suite('Adaption for express application', function() { }); var mockedReceiver; - utils.createClient() - .then(function(newClient) { - clientSocket = newClient.socket; - - mockedReceiver = nodemock - .mock('receive') - .takes('api OK'); - - clientSocket.on('api.response', function(data) { - mockedReceiver.receive(data); - }); - - clientSocket.emit('api', 'request'); + utils.createClients(1) + .then(function(newClients) { + clients = newClients; + clients[0].expectReceive('api.response', 'api OK'); + clients[0].socket.emit('api', 'request'); }) .then(utils.waitCb(0.01)) .then(function() { - mockedReceiver.assertThrows(); + clients[0].assertThrows(); done(); }) .catch(done); -------------- next part -------------- HTML����������������������������... Download