[Groonga-commit] groonga/express-kotoumi [master] test: Test messages from backend correctly

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Feb 7 17:49:01 JST 2013


YUKI Hiroshi	2013-02-07 17:49:01 +0900 (Thu, 07 Feb 2013)

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

  Log:
    test: Test messages from backend correctly

  Modified files:
    test/frontend-socket.io-adaptor.test.js

  Modified: test/frontend-socket.io-adaptor.test.js (+20 -18)
===================================================================
--- test/frontend-socket.io-adaptor.test.js    2013-02-07 17:43:27 +0900 (bd97d5f)
+++ test/frontend-socket.io-adaptor.test.js    2013-02-07 17:49:01 +0900 (42b7594)
@@ -15,6 +15,19 @@ suite('Socket.IO API', function() {
   var server;
   var clientSocket;
 
+  var testPlugin = {
+    'foobar': new model.SocketCommand(),
+    'builder': new model.SocketRequestResponse({
+      toBackend: function(event, data) { return [event, 'builder request']; },
+      toClient: function(event, data) { return [event, 'builder response'] }
+    }),
+    'customevent': new model.SocketRequestResponse({
+      toBackend: function(event, data) { return ['custom', data] },
+      toClient: function(event, data) { return [event, 'custom response']; }
+    }),
+    'pubsub': new model.SocketPublisSubscribe()
+  };
+
   teardown(function() {
     if (connection) {
       utils.readyToDestroyMockedConnection(connection);
@@ -129,7 +142,7 @@ suite('Socket.IO API', function() {
 
         connection = connection
           .mock('emitMessage')
-            .takes('search', { requestMessage: true });
+            .takes('search', { requestMessage: true } function() {}, {});
         clientSocket.emit('search', { requestMessage: true });
       })
       .wait(0.01)
@@ -149,7 +162,7 @@ suite('Socket.IO API', function() {
           .mock('receive')
           .takes({
             statusCode: 200,
-            body:       { searchResult: true }
+            body:       { published: true }
           });
 
     var application = express();
@@ -157,7 +170,8 @@ suite('Socket.IO API', function() {
       .next(function(newServer) {
         server = newServer;
         socketIoAdaptor.register(application, server, {
-          connection: connection
+          connection: connection,
+          plugins: [testPlugin]
         });
 
         return utils.createClientSocket();
@@ -167,14 +181,14 @@ suite('Socket.IO API', function() {
 
         connection.assertThrows();
 
-        clientSocket.on('search.result', function(data) {
+        clientSocket.on('pubsub', function(data) {
           clientReceiver.receive(data);
         });
 
         var envelope = {
-          type:       'search.result',
+          type:       'pubsub',
           statusCode: 200,
-          body:       { searchResult: true}
+          body:       { published: true}
         };
         connection.controllers.search.trigger(envelope);
       })
@@ -188,18 +202,6 @@ suite('Socket.IO API', function() {
       });
   });
 
-  var testPlugin = {
-    'foobar': new model.SocketCommand(),
-    'builder': new model.SocketRequestResponse({
-      toBackend: function() { return 'builder request'; },
-      toClient: function() { return 'builder response' }
-    }),
-    'customevent': new model.SocketRequestResponse({
-      toBackend: 'custom',
-      toClient: function() { return 'custom response' }
-    })
-  };
-
   test('front to back, extra command (without builder)', function(done) {
     var extraController = {};
     connection = utils.createMockedBackendConnection();
-------------- next part --------------
HTML����������������������������...
Download 



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