[Groonga-commit] groonga/express-kotoumi [master] Add test for one-way message from the backend

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Jan 10 19:11:16 JST 2013


YUKI Hiroshi	2013-01-10 19:11:16 +0900 (Thu, 10 Jan 2013)

  New Revision: c6e103b4fa6ce4058e2efdcf76fca606db796759
  https://github.com/groonga/express-kotoumi/commit/c6e103b4fa6ce4058e2efdcf76fca606db796759

  Log:
    Add test for one-way message from the backend

  Modified files:
    test/backend-adaptor.test.js

  Modified: test/backend-adaptor.test.js (+28 -1)
===================================================================
--- test/backend-adaptor.test.js    2013-01-10 19:10:21 +0900 (a66a510)
+++ test/backend-adaptor.test.js    2013-01-10 19:11:16 +0900 (4384c2a)
@@ -136,6 +136,32 @@ suite('Connection', function() {
     sender.assertSent('message', message);
   });
 
+  test('receiving message from the backend', function() {
+    var callback = createMockedMessageCallback();
+    connection.on('message', callback);
+
+    var now = new Date();
+    var message = {
+      id:         now.getTime(),
+      date:       now.toISOString(),
+      statusCode: 200,
+      body:       'first call'
+    };
+    callback.takes(message);
+    receiver.emitMessage(message);
+    callback.assert();
+
+    message.body = 'second call';
+    callback.takes(message);
+    receiver.emitMessage(message);
+    callback.assert();
+
+    message.body = 'third call';
+    connection.removeListener('message', callback);
+    receiver.emitMessage(message);
+    callback.assert();
+  });
+
   test('sending message with one response', function() {
     var callback = createMockedMessageCallback();
     var message = connection.emitMessage({ command: 'foobar' }, callback);
@@ -152,13 +178,14 @@ suite('Connection', function() {
       date:       now.toISOString(),
       replyTo:    message.id,
       statusCode: 200,
-      body:       { response: true }
+      body:       'first call'
     };
     callback.takes(response);
     receiver.emitMessage(response);
     callback.assert();
 
     // Secondary and later messages are ignored.
+    response.body = 'second call';
     receiver.emitMessage(response);
     callback.assert();
   });
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index