[Groonga-commit] groonga/express-kotoumi [master] Test front-to-back communication by socket.io API correctly

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Jan 21 15:36:56 JST 2013


YUKI Hiroshi	2013-01-21 15:36:56 +0900 (Mon, 21 Jan 2013)

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

  Log:
    Test front-to-back communication by socket.io API correctly

  Modified files:
    test/socket-api.test.js

  Modified: test/socket-api.test.js (+16 -4)
===================================================================
--- test/socket-api.test.js    2013-01-21 15:28:10 +0900 (0883863)
+++ test/socket-api.test.js    2013-01-21 15:36:56 +0900 (b0e63cf)
@@ -1,5 +1,6 @@
 var assert = require('chai').assert;
 var nodemock = require('nodemock');
+var Deferred = require('jsdeferred').Deferred;
 
 var utils = require('./test-utils');
 
@@ -19,13 +20,13 @@ suite('Socket.IO API', function() {
     server = undefined;
   });
 
-  test('front to back', function() {
+  test('front to back', function(done) {
     var connection = nodemock
           .mock('on')
             .takes('message', function() {})
             .times(socketAdaptor.commands.length)
           .mock('emitMessage')
-            .takes('search', { requestMessage: true }, function() {});
+            .takes('search', { requestMessage: true });
 
     var application = express();
     server = utils.setupServer(application);
@@ -34,9 +35,20 @@ suite('Socket.IO API', function() {
     });
 
     var clientSocket = client.connect('http://localhost:' + utils.testServerPort);
-    clientSocket.emit('search', { requestMessage: true });
 
-    connection.assertThrows();
+    Deferred
+      .wait(0.1)
+      .next(function() {
+        clientSocket.emit('search', { requestMessage: true });
+      })
+      .wait(0.1)
+      .next(function() {
+        connection.assertThrows();
+        done();
+      })
+      .error(function(error) {
+        done(error);
+      });
   });
 });
 
-------------- next part --------------
HTML����������������������������...
Descargar 



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