YUKI Hiroshi
null+****@clear*****
Wed Feb 6 12:31:01 JST 2013
YUKI Hiroshi 2013-02-06 12:31:01 +0900 (Wed, 06 Feb 2013) New Revision: cc36984429bced25b38714ee3a3571cec202f91e https://github.com/groonga/express-kotoumi/commit/cc36984429bced25b38714ee3a3571cec202f91e Log: Add test for plugin registeration of socket.io adaptor Modified files: test/frontend-socket.io-adaptor.test.js Modified: test/frontend-socket.io-adaptor.test.js (+62 -0) =================================================================== --- test/frontend-socket.io-adaptor.test.js 2013-02-06 12:30:21 +0900 (af0d279) +++ test/frontend-socket.io-adaptor.test.js 2013-02-06 12:31:01 +0900 (f2a8ede) @@ -6,6 +6,7 @@ var express = require('express'); var utils = require('./test-utils'); var socketIoAdaptor = require('../lib/frontend/socket.io-adaptor'); +var scoketIoCommands = require('../lib/frontend/default-commands/socket.io'); var Connection = require('../lib/backend/connection').Connection; suite('Socket.IO API', function() { @@ -28,6 +29,67 @@ suite('Socket.IO API', function() { } }); + test('registeration of plugin commands', function() { + var basePlugin = { + getCommand: { + requestBuilder: function() {} + }, + putCommand: { + requestBuilder: function() {} + }, + postCommand: { + requestBuilder: function() {} + }, + deleteCommand: { + requestBuilder: function() {} + } + }; + var overridingPlugin = { + postCommand: { + requestBuilder: function() {} + }, + deleteCommand: { + requestBuilder: function() {} + } + }; + + utils.setupServer(utils.testServerPort) + .next(function(newServer) { + server = newServer; + + var application = express(); + var registeredCommands = socketIoAdaptor.register(application, server, { + connection: utils.createStubbedBackendConnection(), + plugins: [ + basePlugin, + overridingPlugin + ] + }); + + registeredCommands = registeredCommands.map(function(command) { + return { + command: command.command, + definition: command.definition + }; + }); + assert.deepEqual(registeredCommands, + [{ command: 'search', + definition: scoketIoCommands.search }, + { command: 'getCommand', + definition: basePlugin.getCommand }, + { command: 'putCommand', + definition: basePlugin.putCommand }, + { command: 'postCommand', + definition: overridingPlugin.postCommand }, + { command: 'deleteCommand', + definition: overridingPlugin.deleteCommand }]); + done(); + }) + .error(function(error) { + done(error); + }); + }); + test('initialization', function(done) { var mockedListener = nodemock .mock('connected'); -------------- next part -------------- HTML����������������������������... Download