YUKI Hiroshi
null+****@clear*****
Mon Feb 4 12:32:12 JST 2013
YUKI Hiroshi 2013-02-04 12:32:12 +0900 (Mon, 04 Feb 2013) New Revision: 6f6aa60b1fb0b9401d8824039651405e73e4ef89 https://github.com/groonga/express-kotoumi/commit/6f6aa60b1fb0b9401d8824039651405e73e4ef89 Log: test: Define utils.createStubbedBackendConnection() utility Modified files: test/express-adaptor.test.js test/frontend-rest-handler.test.js test/test-utils.js Modified: test/express-adaptor.test.js (+2 -10) =================================================================== --- test/express-adaptor.test.js 2013-02-04 12:11:24 +0900 (f66f38c) +++ test/express-adaptor.test.js 2013-02-04 12:32:12 +0900 (8181d8f) @@ -31,16 +31,8 @@ suite('Adaption for express application', function() { } }); - function createFakeConnection() { - return { - emitMessage: function() {}, - emit: function() {}, - on: function() {} - }; - } - test('to the document root', function(done) { - var fakeConnection = createFakeConnection(); + var fakeConnection = utils.createStubbedBackendConnection(); var application = express(); application.kotoumi({ prefix: '', @@ -63,7 +55,7 @@ suite('Adaption for express application', function() { }); test('under specified path', function(done) { - var fakeConnection = createFakeConnection(); + var fakeConnection = utils.createStubbedBackendConnection(); var application = express(); application.kotoumi({ prefix: '/path/to/kotoumi', Modified: test/frontend-rest-handler.test.js (+3 -11) =================================================================== --- test/frontend-rest-handler.test.js 2013-02-04 12:11:24 +0900 (c2b61c3) +++ test/frontend-rest-handler.test.js 2013-02-04 12:32:12 +0900 (747d903) @@ -8,16 +8,8 @@ var restHandler = require('../lib/frontend/rest-handler'); var Connection = require('../lib/backend/connection').Connection; suite('REST API', function() { - function createFakeConnection() { - return { - emitMessage: function() {}, - emit: function() {}, - on: function() {} - }; - } - test('registeration for given handlers', function() { - var fakeConnection = createFakeConnection(); + var fakeConnection = utils.createStubbedBackendConnection(); var mockedHandlers = nodemock.mock('search') .takes(fakeConnection) .returns(function() {}); @@ -52,7 +44,7 @@ suite('REST API', function() { }); test('to the document root', function(done) { - var fakeConnection = createFakeConnection(); + var fakeConnection = utils.createStubbedBackendConnection(); var application = express(); restHandler.register(application, { prefix: '', @@ -74,7 +66,7 @@ suite('REST API', function() { }); test('under specified path', function(done) { - var fakeConnection = createFakeConnection(); + var fakeConnection = utils.createStubbedBackendConnection(); var application = express(); restHandler.register(application, { prefix: '/path/to/kotoumi', Modified: test/test-utils.js (+11 -0) =================================================================== --- test/test-utils.js 2013-02-04 12:11:24 +0900 (032436c) +++ test/test-utils.js 2013-02-04 12:32:12 +0900 (9739fd9) @@ -157,6 +157,17 @@ function createMockedBackendConnection() { } exports.createMockedBackendConnection = createMockedBackendConnection; +function createStubbedBackendConnection() { + return { + emitMessage: function() {}, + emit: function() {}, + on: function() {}, + removeListener: function(), + removeAllListeners: function() + }; +} +exports.createStubbedBackendConnection = createStubbedBackendConnection; + function readyToDestroyMockedConnection(connection) { connection = connection .mock('removeListener') -------------- next part -------------- HTML����������������������������... 다운로드