YUKI Hiroshi
null+****@clear*****
Fri Oct 17 19:27:14 JST 2014
YUKI Hiroshi 2014-10-17 19:27:14 +0900 (Fri, 17 Oct 2014) New Revision: 1c8d156017751f524c2347c8958bcc214458d9fe https://github.com/droonga/express-droonga/commit/1c8d156017751f524c2347c8958bcc214458d9fe Message: Define utility getter to get formatted emitted messages Modified files: test/adapter/http.test.js test/adapter/socket.io.test.js test/test-utils.js Modified: test/adapter/http.test.js (+1 -8) =================================================================== --- test/adapter/http.test.js 2014-10-17 19:18:25 +0900 (91ff6c1) +++ test/adapter/http.test.js 2014-10-17 19:27:14 +0900 (9d409a1) @@ -289,14 +289,7 @@ suite('HTTP Adapter', function() { .then(function(response) { responses.push(response); }) .then(function() { assert.deepEqual( - connectionPool.connections.map(function(connection) { - return connection.emitMessageCalledArguments.map(function(args) { - return { - type: args.type, - message: args.message - }; - }); - }), + connectionPool.emittedMessages, [ [{ type: 'adapter', message: 'requested 1' }, { type: 'adapter', message: 'requested 4' }], Modified: test/adapter/socket.io.test.js (+3 -15) =================================================================== --- test/adapter/socket.io.test.js 2014-10-17 19:18:25 +0900 (91f10b9) +++ test/adapter/socket.io.test.js 2014-10-17 19:27:14 +0900 (0da1b53) @@ -192,10 +192,7 @@ suite('Socket.IO Adapter', function() { .then(utils.waitCb(0.01)) .then(function() { assert.deepEqual( - connection.emitMessageCalledArguments.map(function(args) { - return { type: args.type, - message: args.message }; - }), + connection.emittedMessages, [ { type: params.expectedRequest, message: params.body } @@ -285,10 +282,7 @@ suite('Socket.IO Adapter', function() { clientSockets[2].emit('reqrep', messages[5]); }).then(utils.waitCb(0.01)).then(function() { assert.deepEqual( - connection.emitMessageCalledArguments.map(function(args) { - return { type: args.type, - message: args.message }; - }), + connection.emittedMessages, messages.map(function(message) { return { type: 'reqrep', message: message }; @@ -339,13 +333,7 @@ suite('Socket.IO Adapter', function() { { responseEvent: 'reqrep-mod-event.extra.name' }); }).then(utils.waitCb(0.01)).then(function() { assert.deepEqual( - connection.emitMessageCalledArguments.map(function(args) { - var options = {}; - if (args.options) - options.responseEvent = args.options.responseEvent; - return { type: args.type, - message: args.message }; - }), + connection.emittedMessages, [ { type: 'reqrep', message: 'message1' }, Modified: test/test-utils.js (+16 -2) =================================================================== --- test/test-utils.js 2014-10-17 19:18:25 +0900 (a60088e) +++ test/test-utils.js 2014-10-17 19:27:14 +0900 (d55dc9b) @@ -234,7 +234,16 @@ function createStubbedBackendConnection(hostName) { on: function() {}, removeListener: function() {}, removeAllListeners: function() {}, - close: function() {} + close: function() {}, + + get emittedMessages() { + return this.emitMessageCalledArguments.map(function(args) { + return { + type: args.type, + message: args.message + }; + }); + } }; } exports.createStubbedBackendConnection = createStubbedBackendConnection; @@ -257,7 +266,12 @@ function createStubbedBackendConnectionPool(count) { }, closeAll: function() {}, - connections: connections + connections: connections, + get emittedMessages() { + return this.connections.map(function(connection) { + return connection.emittedMessages; + }); + } }; } exports.createStubbedBackendConnectionPool = createStubbedBackendConnectionPool; -------------- next part -------------- HTML����������������������������...Download