[Pkg-javascript-commits] [sockjs-client] 77/350: Upgrade tests to use node assert and mocha async tests. Upgrade deps

tonnerre at ancient-solutions.com tonnerre at ancient-solutions.com
Fri Aug 5 01:03:44 UTC 2016


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.

commit 566d29e7ece56543d5fb592d86d08b8a7009c27f
Author: Bryce Kahle <bkahle at gmail.com>
Date:   Tue Aug 12 14:17:13 2014 -0400

    Upgrade tests to use node assert and mocha async tests. Upgrade deps
---
 .zuul.yml                       |   2 +-
 package.json                    |  19 ++--
 tests/html/lib/domtests.js      | 130 +++++++++++++++------------
 tests/html/lib/endtoendtests.js |  96 ++++++++++----------
 tests/html/lib/tests.js         | 147 ++++++++++++++++--------------
 tests/html/lib/unittests.js     | 194 ++++++++++++++++++++--------------------
 6 files changed, 308 insertions(+), 280 deletions(-)

diff --git a/.zuul.yml b/.zuul.yml
index dea9388..4f6f7af 100644
--- a/.zuul.yml
+++ b/.zuul.yml
@@ -1,4 +1,4 @@
-ui: qunit
+ui: mocha-qunit
 scripts:
   - "static/jquery.min.js"
   - "config.js"
diff --git a/package.json b/package.json
index e1d6985..df0ca55 100644
--- a/package.json
+++ b/package.json
@@ -13,20 +13,19 @@
     }
   ],
   "dependencies": {
-    "json3": "^3.3.1"
+    "json3": "^3.3.2"
   },
   "devDependencies": {
-    "browserify": "^4.1.5",
+    "browserify": "^4.2.3",
     "exorcist": "^0.1.6",
-    "gulp": "^3.6.2",
-    "gulp-util": "^2.2.14",
-    "minifyify": "^3.0.6",
-    "mocha": "^1.18.2",
+    "gulp": "^3.8.7",
+    "minifyify": "^3.0.12",
+    "mocha": "^1.21.4",
     "mold-source-map": "^0.3.0",
-    "node-static": "0.5.9",
-    "sockjs": "^0.3.8",
+    "node-static": "^0.5.9",
+    "sockjs": "^0.3.9",
     "vinyl-source-stream": "^0.1.1",
-    "zuul": "^1.6.4"
+    "zuul": "^1.10.1"
   },
   "homepage": "http://sockjs.org",
   "keywords": [
@@ -41,6 +40,6 @@
   },
   "scripts": {
     "test": "./node_modules/zuul/bin/zuul -- tests/html/lib/unittests.js tests/html/lib/domtests.js tests/html/lib/endtoendtests.js tests/html/lib/tests.js",
-    "test_local": "./node_modules/zuul/bin/zuul --local 9090 --ui qunit -- tests/html/lib/unittests.js tests/html/lib/domtests.js tests/html/lib/endtoendtests.js tests/html/lib/tests.js"
+    "test_local": "./node_modules/zuul/bin/zuul --local 9090 -- tests/html/lib/unittests.js tests/html/lib/domtests.js tests/html/lib/endtoendtests.js tests/html/lib/tests.js"
   }
 }
diff --git a/tests/html/lib/domtests.js b/tests/html/lib/domtests.js
index cce7270..b1e9570 100644
--- a/tests/html/lib/domtests.js
+++ b/tests/html/lib/domtests.js
@@ -1,74 +1,81 @@
 'use strict';
-/* global expect, ok, QUnit, start, test, asyncTest, SockJS, equal */
+/* global suite, test */
 var ajax_simple_factory, ajax_streaming_factory, ajax_wrong_port_factory, onunload_test_factory, test_wrong_url;
 
-QUnit.module('Dom');
+suite('DOM');
 
+var assert = require('assert');
 var u = require('../../../lib/utils');
 var testutils = require('./testutils');
 
-onunload_test_factory = function(code) {
-  return function() {
-    var hook;
-    expect(3);
-    hook = testutils.newIframe();
-    hook.open = function() {
-      ok(true, 'open hook called by an iframe');
-      return hook.callback(code);
-    };
-    hook.load = function() {
-      var f;
-      ok(true, 'onload hook called by an iframe');
-      f = function() {
-        return hook.iobj.cleanup();
-      };
-      return setTimeout(f, 1);
-    };
-    hook.unload = function() {
-      ok(true, 'onunload hook called by an iframe');
-      hook.del();
-      start();
+onunload_test_factory = function(code, done) {
+  var hook;
+  //expect(3);
+  hook = testutils.newIframe();
+  hook.open = function() {
+    assert.ok(true, 'open hook called by an iframe');
+    return hook.callback(code);
+  };
+  hook.load = function() {
+    var f;
+    assert.ok(true, 'onload hook called by an iframe');
+    f = function() {
+      return hook.iobj.cleanup();
     };
+    return setTimeout(f, 1);
+  };
+  hook.unload = function() {
+    assert.ok(true, 'onunload hook called by an iframe');
+    hook.del();
+    done();
   };
 };
 
 if (navigator.userAgent.indexOf('Konqueror') !== -1 || navigator.userAgent.indexOf('Opera') !== -1) {
   test("onunload [unsupported by client]", function() {
-    ok(true);
+    assert.ok(true);
   });
 } else {
-  asyncTest('onunload', onunload_test_factory("var u = SockJS.getUtils();\nu.attachEvent('load', function(){\n    hook.load();\n});\nvar w = 0;\nvar run = function(){\n    if(w === 0) {\n        w = 1;\n        hook.unload();\n    }\n};\nu.attachEvent('beforeunload', run);\nu.attachEvent('unload', run);"));
+  test('onunload', function (done) {
+    this.timeout(5000);
+    this.runnable().globals(['_sockjs_global']);
+    onunload_test_factory("var u = SockJS.getUtils();\nu.attachEvent('load', function(){\n    hook.load();\n});\nvar w = 0;\nvar run = function(){\n    if(w === 0) {\n        w = 1;\n        hook.unload();\n    }\n};\nu.attachEvent('beforeunload', run);\nu.attachEvent('unload', run);", done);
+  });
 }
 
 if (!require('../../../lib/trans-iframe').enabled()) {
   test("onmessage [unsupported by client]", function() {
-    ok(true);
+    assert.ok(true);
   });
 } else {
-  asyncTest('onmessage', function() {
+  test('onmessage', function(done) {
+    this.runnable().globals(['_sockjs_global']);
     var hook;
-    expect(3);
+    //expect(3);
     hook = testutils.newIframe();
     hook.open = function() {
-      ok(true, 'open hook called by an iframe');
+      assert.ok(true, 'open hook called by an iframe');
       hook.callback("var u = SockJS.getUtils();\nu.attachMessage(function(e) {\n    var b = e.data;\n    parent.postMessage(window_id + ' ' + 'e', '*');\n});\nparent.postMessage(window_id + ' ' + 's', '*');");
     };
     u.attachMessage(function(e) {
-      var data, origin, window_id, _ref;
-      _ref = e.data.split(' '), window_id = _ref[0], data = _ref[1];
+      var _ref = e.data.split(' ')
+        , window_id = _ref[0]
+        , data = _ref[1]
+        , origin
+        ;
       if (window_id === hook.id) {
         switch (data) {
           case 's':
             hook.iobj.loaded();
-            ok(true, 'start frame send');
+            assert.ok(true, 'start frame send');
             origin = u.getOrigin(u.amendUrl('/'));
             hook.iobj.post(hook.id + ' ' + 's', origin);
             break;
           case 'e':
-            ok(true, 'done hook called by an iframe');
+            assert.ok(true, 'done hook called by an iframe');
             hook.iobj.cleanup();
             hook.del();
-            start();
+            done();
             break;
         }
       }
@@ -77,50 +84,52 @@ if (!require('../../../lib/trans-iframe').enabled()) {
 }
 
 ajax_simple_factory = function(name, Obj) {
-  asyncTest(name + ' simple', function() {
+  test(name + ' simple', function(done) {
+    this.runnable().globals(['_sockjs_global']);
     var x;
-    expect(2);
+    //expect(2);
     x = new Obj('GET', '/simple.txt', null);
     x.onfinish = function(status, text) {
-      equal(text.length, 2051);
-      equal(text.slice(-2), 'b\n');
-      start();
+      assert.equal(text.length, 2051);
+      assert.equal(text.slice(-2), 'b\n');
+      done();
     };
   });
 };
 
 ajax_streaming_factory = function(name, Obj) {
-  asyncTest(name + ' streaming', function() {
+  test(name + ' streaming', function(done) {
+    this.runnable().globals(['_sockjs_global']);
     var x;
-    expect(4);
+    //expect(4);
     x = new Obj('GET', '/streaming.txt', null);
     x.onchunk = function(status, text) {
-      equal(status, 200);
-      ok(text.length <= 2049, 'Most likely you\'re behind a transparent Proxy that can\'t do streaming. QUnit tests won\'t work properly. Sorry!');
+      assert.equal(status, 200);
+      assert.ok(text.length <= 2049, 'Most likely you\'re behind a transparent Proxy that can\'t do streaming. QUnit tests won\'t work properly. Sorry!');
       delete x.onchunk;
     };
-    return x.onfinish = function(status, text) {
-      equal(status, 200);
-      equal(text.slice(-4), 'a\nb\n');
-      start();
+    x.onfinish = function(status, text) {
+      assert.equal(status, 200);
+      assert.equal(text.slice(-4), 'a\nb\n');
+      done();
     };
   });
 };
 
-test_wrong_url = function(name, Obj, url, statuses) {
+test_wrong_url = function(name, Obj, url, statuses, done) {
   var x;
   if (window.console && console.log) {
     console.log(' [*] Connecting to wrong url ' + url);
   }
-  expect(2);
+  //expect(2);
   x = new Obj('GET', url, null);
   x.onchunk = function() {
-    ok(false, "chunk shall not be received");
+    assert.ok(false, "chunk shall not be received");
   };
   x.onfinish = function(status, text) {
-    ok(u.arrIndexOf(statuses, status) !== -1);
-    equal(text, '');
-    start();
+    assert.ok(u.arrIndexOf(statuses, status) !== -1);
+    assert.equal(text, '');
+    done();
   };
 };
 
@@ -129,8 +138,9 @@ ajax_wrong_port_factory = function(name, Obj) {
   _ref = [25, 8999, 65300];
   for (_i = 0, _len = _ref.length; _i < _len; _i++) {
     port = _ref[_i];
-    asyncTest(name + ' wrong port ' + port, function() {
-      test_wrong_url(name, Obj, 'http://localhost:' + port + '/wrong_url_indeed.txt', [0]);
+    test(name + ' wrong port ' + port, function(done) {
+      this.runnable().globals(['_sockjs_global']);
+      test_wrong_url(name, Obj, 'http://localhost:' + port + '/wrong_url_indeed.txt', [0], done);
     });
   }
 };
@@ -150,12 +160,14 @@ ajax_wrong_port_factory('XHRLocalObject', XHRLocalObject);
 
 if (window.XDomainRequest) ajax_wrong_port_factory('XDRObject', XDRObject);
 
-asyncTest('XHRLocalObject wrong url', function() {
-  test_wrong_url('XHRLocalObject', XHRLocalObject, '/wrong_url_indeed.txt', [0, 404]);
+test('XHRLocalObject wrong url', function(done) {
+  this.runnable().globals(['_sockjs_global']);
+  test_wrong_url('XHRLocalObject', XHRLocalObject, '/wrong_url_indeed.txt', [0, 404], done);
 });
 
 if (window.XDomainRequest) {
-  asyncTest('XDRObject wrong url', function() {
-    test_wrong_url('XDRObject', XDRObject, '/wrong_url_indeed.txt', [0]);
+  test('XDRObject wrong url', function(done) {
+    this.runnable().globals(['_sockjs_global']);
+    test_wrong_url('XDRObject', XDRObject, '/wrong_url_indeed.txt', [0], done);
   });
 }
diff --git a/tests/html/lib/endtoendtests.js b/tests/html/lib/endtoendtests.js
index f687650..2383756 100644
--- a/tests/html/lib/endtoendtests.js
+++ b/tests/html/lib/endtoendtests.js
@@ -1,108 +1,114 @@
 'use strict';
-/* global expect, ok, QUnit, start, asyncTest, equal */
+/* global test, suite */
 
+var assert = require('assert');
 var u = require('../../../lib/utils');
 var testutils = require('./testutils');
 
-QUnit.module('End to End');
+suite('End to End');
 
-QUnit.module('connection errors');
+suite('Connection Errors');
 
-asyncTest("invalid url 404", function() {
+test("invalid url 404", function(done) {
+  this.runnable().globals(['_sockjs_global']);
   var r;
-  expect(4);
+  //expect(4);
   r = testutils.newSockJS('/invalid_url', 'jsonp-polling');
-  ok(r);
+  assert.ok(r);
   r.onopen = function(e) {
-    ok(false);
+    assert.ok(false);
   };
   r.onmessage = function(e) {
-    ok(false);
+    assert.ok(false);
   };
   r.onclose = function(e) {
     if (u.isXHRCorsCapable() < 4) {
-      equal(e.code, 1002);
-      equal(e.reason, 'Can\'t connect to server');
+      assert.equal(e.code, 1002);
+      assert.equal(e.reason, 'Can\'t connect to server');
     } else {
-      equal(e.code, 2000);
-      equal(e.reason, 'All transports failed');
+      assert.equal(e.code, 2000);
+      assert.equal(e.reason, 'All transports failed');
     }
-    equal(e.wasClean, false);
-    start();
+    assert.equal(e.wasClean, false);
+    done();
   };
 });
 
-asyncTest("invalid url port", function() {
+test("invalid url port", function(done) {
+  this.runnable().globals(['_sockjs_global']);
   var dl, r;
-  expect(4);
+  //expect(4);
   dl = document.location;
   r = testutils.newSockJS(dl.protocol + '//' + dl.hostname + ':1079', 'jsonp-polling');
-  ok(r);
+  assert.ok(r);
   r.onopen = function(e) {
-    ok(false);
+    assert.ok(false);
   };
   r.onclose = function(e) {
     if (u.isXHRCorsCapable() < 4) {
-      equal(e.code, 1002);
-      equal(e.reason, 'Can\'t connect to server');
+      assert.equal(e.code, 1002);
+      assert.equal(e.reason, 'Can\'t connect to server');
     } else {
-      equal(e.code, 2000);
-      equal(e.reason, 'All transports failed');
+      assert.equal(e.code, 2000);
+      assert.equal(e.reason, 'All transports failed');
     }
-    equal(e.wasClean, false);
-    start();
+    assert.equal(e.wasClean, false);
+    done();
   };
 });
 
-asyncTest("disabled websocket test", function() {
+test("disabled websocket test", function(done) {
+  this.runnable().globals(['_sockjs_global']);
   var r;
-  expect(3);
+  //expect(3);
   r = testutils.newSockJS('/disabled_websocket_echo', 'websocket');
   r.onopen = function(e) {
-    ok(false);
+    assert.ok(false);
   };
   r.onmessage = function(e) {
-    ok(false);
+    assert.ok(false);
   };
   r.onclose = function(e) {
-    equal(e.code, 2000);
-    equal(e.reason, "All transports failed");
-    equal(e.wasClean, false);
-    start();
+    assert.equal(e.code, 2000);
+    assert.equal(e.reason, "All transports failed");
+    assert.equal(e.wasClean, false);
+    done();
   };
 });
 
-asyncTest("close on close", function() {
+test("close on close", function(done) {
+  this.runnable().globals(['_sockjs_global', '_jp']);
   var r;
-  expect(4);
+  //expect(4);
   r = testutils.newSockJS('/close', 'jsonp-polling');
   r.onopen = function(e) {
-    ok(true);
+    assert.ok(true);
   };
   r.onmessage = function(e) {
-    ok(false);
+    assert.ok(false);
   };
   r.onclose = function(e) {
-    equal(e.code, 3000);
-    equal(e.reason, "Go away!");
-    equal(e.wasClean, true);
+    assert.equal(e.code, 3000);
+    assert.equal(e.reason, "Go away!");
+    assert.equal(e.wasClean, true);
     r.onclose = function() {
-      ok(false);
+      assert.ok(false);
     };
     r.close();
     u.delay(10, function() {
-      start();
+      done();
     });
   };
 });
 
-asyncTest("EventEmitter exception handling", function() {
+test("EventEmitter exception handling", function(done) {
+  this.runnable().globals(['_sockjs_global', '_jp']);
   var prev_onerror, r;
-  expect(1);
+  //expect(1);
   r = testutils.newSockJS('/echo', 'xhr-streaming');
   prev_onerror = window.onerror;
   window.onerror = function(e) {
-    ok(/onopen error/.test('' + e));
+    assert.ok(/onopen error/.test('' + e));
     window.onerror = prev_onerror;
     r.close();
   };
@@ -110,6 +116,6 @@ asyncTest("EventEmitter exception handling", function() {
     throw "onopen error";
   };
   r.onclose = function() {
-    start();
+    done();
   };
 });
diff --git a/tests/html/lib/tests.js b/tests/html/lib/tests.js
index 01d8da8..f5eeaf5 100644
--- a/tests/html/lib/tests.js
+++ b/tests/html/lib/tests.js
@@ -1,18 +1,23 @@
 'use strict';
-/* global expect, ok, QUnit, start, test, asyncTest, SockJS, equal, client_opts */
+/* global suite, test, SockJS, client_opts */
 var arrIndexOf, batch_factory_factory, batch_factory_factory_amp, echo_factory_factory, escapable, factor_batch_large, factor_batch_large_amp, factor_echo_basic, factor_echo_from_child, factor_echo_large_message, factor_echo_rich, factor_echo_special_chars, factor_echo_unicode, factor_echo_utf_encoding, factor_echo_utf_encoding_simple, factor_server_close, factor_user_close, generate_killer_string, test_protocol_messages;
 
+var assert = require('assert');
 var u = require('../../../lib/utils');
 var testutils = require('./testutils');
 
+var TIMEOUT_MS = 10000;
+
 echo_factory_factory = function(protocol, messages) {
-  return function() {
+  return function(done) {
+    this.timeout(TIMEOUT_MS);
+    this.runnable().globals(['_sockjs_global', '_jp', '_send_form', '_send_area']);
     var a, r;
-    expect(2 + messages.length);
+    //expect(2 + messages.length);
     a = messages.slice(0);
     r = testutils.newSockJS('/echo', protocol);
     r.onopen = function(e) {
-      ok(true);
+      assert.ok(true);
       r.send(a[0]);
     };
     r.onmessage = function(e) {
@@ -28,7 +33,7 @@ echo_factory_factory = function(protocol, messages) {
           }
         }
       }
-      equal(e.data, '' + a[0]);
+      assert.equal(e.data, '' + a[0]);
       a.shift();
       if (typeof a[0] === 'undefined') {
         r.close();
@@ -38,11 +43,11 @@ echo_factory_factory = function(protocol, messages) {
     };
     r.onclose = function(e) {
       if (a.length) {
-        ok(false, "Transport closed prematurely. " + e);
+        assert.ok(false, "Transport closed prematurely. " + e);
       } else {
-        ok(true);
+        assert.ok(true);
       }
-      start();
+      done();
     };
   };
 };
@@ -65,44 +70,46 @@ factor_echo_rich = function(protocol) {
 };
 
 factor_echo_from_child = function(protocol) {
-  return function() {
+  return function(done) {
+    this.timeout(TIMEOUT_MS);
+    this.runnable().globals(['_sockjs_global', '_jp', '_send_form', '_send_area']);
     var code, hook, hookReady, r, sockJSReady, timeout;
     timeout = void 0;
     hookReady = false;
     sockJSReady = false;
-    expect(4);
+    //expect(4);
     hook = testutils.newIframe("sockjs-in-parent.html");
     r = testutils.newSockJS("/echo", protocol);
     code = "hook.r.send('a'); hook.onsend();";
     hook.open = function() {
       hook.iobj.loaded();
-      ok(true, "iframe open");
+      assert.ok(true, "iframe open");
       hookReady = true;
       hook.r = r;
       sockJSReady && hook.callback(code);
     };
     r.onopen = function(e) {
       hook.iobj.loaded();
-      ok(true, "sockjs open");
+      assert.ok(true, "sockjs open");
       sockJSReady = true;
       hookReady && hook.callback(code);
     };
     r.onmessage = function(e) {
       clearTimeout(timeout);
-      equal(e.data, "a");
-      ok(true, "onmessage");
+      assert.equal(e.data, "a");
+      assert.ok(true, "onmessage");
       hook.iobj.cleanup();
       hook.del();
       r.close();
     };
     hook.onsend = function(e) {
       timeout = setTimeout(function() {
-        ok(false);
+        assert.ok(false);
         r.close();
       }, 300);
     };
     r.onclose = function() {
-      start();
+      done();
     };
   };
 };
@@ -121,74 +128,78 @@ factor_echo_special_chars = function(protocol) {
 
 factor_echo_large_message = function(protocol) {
   var messages;
-  messages = [Array(Math.pow(2, 1)).join('x'), Array(Math.pow(2, 2)).join('x'), Array(Math.pow(2, 4)).join('x'), Array(Math.pow(2, 8)).join('x'), Array(Math.pow(2, 13)).join('x'), Array(Math.pow(2, 13)).join('x')];
+  messages = [new Array(Math.pow(2, 1)).join('x'), new Array(Math.pow(2, 2)).join('x'), new Array(Math.pow(2, 4)).join('x'), new Array(Math.pow(2, 8)).join('x'), new Array(Math.pow(2, 13)).join('x'), new Array(Math.pow(2, 13)).join('x')];
   return echo_factory_factory(protocol, messages);
 };
 
 batch_factory_factory = function(protocol, messages) {
-  return function() {
+  return function(done) {
+    this.timeout(TIMEOUT_MS);
+    this.runnable().globals(['_sockjs_global', '_jp', '_send_form', '_send_area']);
     var counter, r;
-    expect(3 + messages.length);
+    //expect(3 + messages.length);
     r = testutils.newSockJS('/echo', protocol);
-    ok(r);
+    assert.ok(r);
     counter = 0;
     r.onopen = function(e) {
       var msg, _i, _len;
-      ok(true);
+      assert.ok(true);
       for (_i = 0, _len = messages.length; _i < _len; _i++) {
         msg = messages[_i];
         r.send(msg);
       }
     };
     r.onmessage = function(e) {
-      equal(e.data, messages[counter]);
+      assert.equal(e.data, messages[counter]);
       counter += 1;
       if (counter === messages.length) r.close();
     };
     r.onclose = function(e) {
       if (counter !== messages.length) {
-        ok(false, "Transport closed prematurely. " + e);
+        assert.ok(false, "Transport closed prematurely. " + e);
       } else {
-        ok(true);
+        assert.ok(true);
       }
-      start();
+      done();
     };
   };
 };
 
 factor_batch_large = function(protocol) {
   var messages;
-  messages = [Array(Math.pow(2, 1)).join('x'), Array(Math.pow(2, 2)).join('x'), Array(Math.pow(2, 4)).join('x'), Array(Math.pow(2, 8)).join('x'), Array(Math.pow(2, 13)).join('x'), Array(Math.pow(2, 13)).join('x')];
+  messages = [new Array(Math.pow(2, 1)).join('x'), new Array(Math.pow(2, 2)).join('x'), new Array(Math.pow(2, 4)).join('x'), new Array(Math.pow(2, 8)).join('x'), new Array(Math.pow(2, 13)).join('x'), new Array(Math.pow(2, 13)).join('x')];
   return batch_factory_factory(protocol, messages);
 };
 
 batch_factory_factory_amp = function(protocol, messages) {
-  return function() {
+  return function(done) {
+    this.timeout(TIMEOUT_MS);
+    this.runnable().globals(['_sockjs_global', '_jp', '_send_form', '_send_area']);
     var counter, r;
-    expect(3 + messages.length);
+    //expect(3 + messages.length);
     r = testutils.newSockJS('/amplify', protocol);
-    ok(r);
+    assert.ok(r);
     counter = 0;
     r.onopen = function(e) {
       var msg, _i, _len;
-      ok(true);
+      assert.ok(true);
       for (_i = 0, _len = messages.length; _i < _len; _i++) {
         msg = messages[_i];
         r.send('' + msg);
       }
     };
     r.onmessage = function(e) {
-      equal(e.data.length, Math.pow(2, messages[counter]), e.data);
+      assert.equal(e.data.length, Math.pow(2, messages[counter]), e.data);
       counter += 1;
       if (counter === messages.length) r.close();
     };
     r.onclose = function(e) {
       if (counter !== messages.length) {
-        ok(false, "Transport closed prematurely. " + e);
+        assert.ok(false, "Transport closed prematurely. " + e);
       } else {
-        ok(true);
+        assert.ok(true);
       }
-      start();
+      done();
     };
   };
 };
@@ -240,49 +251,51 @@ factor_echo_utf_encoding = function(protocol) {
 };
 
 factor_user_close = function(protocol) {
-  return function() {
+  return function(done) {
+    this.runnable().globals(['_sockjs_global', '_jp', '_send_form', '_send_area']);
     var counter, r;
-    expect(5);
+    //expect(5);
     r = testutils.newSockJS('/echo', protocol);
-    ok(r);
+    assert.ok(r);
     counter = 0;
     r.onopen = function(e) {
       counter += 1;
-      ok(counter === 1);
+      assert.ok(counter === 1);
       r.close(3000, "User message");
-      ok(counter === 1);
+      assert.ok(counter === 1);
     };
     r.onmessage = function() {
-      ok(false);
+      assert.ok(false);
       counter += 1;
     };
     r.onclose = function(e) {
       counter += 1;
       u.log('user_close ' + e.code + ' ' + e.reason);
-      equal(e.wasClean, true);
-      ok(counter === 2);
-      start();
+      assert.equal(e.wasClean, true);
+      assert.ok(counter === 2);
+      done();
     };
   };
 };
 
 factor_server_close = function(protocol) {
-  return function() {
+  return function(done) {
+    this.runnable().globals(['_sockjs_global', '_jp', '_send_form', '_send_area']);
     var r;
-    expect(5);
+    //expect(5);
     r = testutils.newSockJS('/close', protocol);
-    ok(r);
+    assert.ok(r);
     r.onopen = function(e) {
-      ok(true);
+      assert.ok(true);
     };
     r.onmessage = function(e) {
-      ok(false);
+      assert.ok(false);
     };
     r.onclose = function(e) {
-      equal(e.code, 3000);
-      equal(e.reason, "Go away!");
-      equal(e.wasClean, true);
-      start();
+      assert.equal(e.code, 3000);
+      assert.equal(e.reason, "Go away!");
+      assert.equal(e.wasClean, true);
+      done();
     };
   };
 };
@@ -296,28 +309,28 @@ arrIndexOf = function(arr, obj) {
 };
 
 test_protocol_messages = function(protocol) {
-  QUnit.module(protocol);
+  suite(protocol);
   if (!SockJS[protocol] || !SockJS[protocol].enabled(client_opts.url)) {
     test("[unsupported by client]", function() {
-      ok(true, 'Unsupported protocol (by client): "' + protocol + '"');
+      assert.ok(true, 'Unsupported protocol (by client): "' + protocol + '"');
     });
   } else if (client_opts.disabled_transports && arrIndexOf(client_opts.disabled_transports, protocol) !== -1) {
     test("[disabled by config]", function() {
-      ok(true, 'Disabled by config: "' + protocol + '"');
+      assert.ok(true, 'Disabled by config: "' + protocol + '"');
     });
   } else {
-    asyncTest("echo1", factor_echo_basic(protocol));
-    asyncTest("echo2", factor_echo_rich(protocol));
-    asyncTest("echo from child", factor_echo_from_child(protocol));
-    asyncTest("unicode", factor_echo_unicode(protocol));
-    asyncTest("utf encoding 0x00-0xFF", factor_echo_utf_encoding_simple(protocol));
-    asyncTest("utf encoding killer message", factor_echo_utf_encoding(protocol));
-    asyncTest("special_chars", factor_echo_special_chars(protocol));
-    asyncTest("large message (ping-pong)", factor_echo_large_message(protocol));
-    asyncTest("large message (batch)", factor_batch_large(protocol));
-    asyncTest("large download", factor_batch_large_amp(protocol));
-    asyncTest("user close", factor_user_close(protocol));
-    asyncTest("server close", factor_server_close(protocol));
+    test("echo1", factor_echo_basic(protocol));
+    test("echo2", factor_echo_rich(protocol));
+    test("echo from child", factor_echo_from_child(protocol));
+    test("unicode", factor_echo_unicode(protocol));
+    test("utf encoding 0x00-0xFF", factor_echo_utf_encoding_simple(protocol));
+    test("utf encoding killer message", factor_echo_utf_encoding(protocol));
+    test("special_chars", factor_echo_special_chars(protocol));
+    test("large message (ping-pong)", factor_echo_large_message(protocol));
+    test("large message (batch)", factor_batch_large(protocol));
+    test("large download", factor_batch_large_amp(protocol));
+    test("user close", factor_user_close(protocol));
+    test("server close", factor_server_close(protocol));
   }
 };
 
diff --git a/tests/html/lib/unittests.js b/tests/html/lib/unittests.js
index 76506c5..b171d96 100644
--- a/tests/html/lib/unittests.js
+++ b/tests/html/lib/unittests.js
@@ -1,55 +1,54 @@
 'use strict';
-/* global expect, ok, QUnit, test, SockJS, equal, notEqual, deepEqual, raises */
-
-QUnit.module('Utils');
+/* global test, SockJS */
 
+var assert = require('assert');
 var u = require('../../../lib/utils');
 
 test('random_string', function() {
   var i, _i, _len, _ref;
-  notEqual(u.random_string(8), u.random_string(8));
+  assert.notEqual(u.random_string(8), u.random_string(8));
   _ref = [1, 2, 3, 128];
   for (_i = 0, _len = _ref.length; _i < _len; _i++) {
     i = _ref[_i];
-    equal(u.random_string(i).length, i);
+    assert.equal(u.random_string(i).length, i);
   }
 });
 
 test('random_number_string', function() {
   for (var i = 0; i <= 10; i++) {
-    equal(u.random_number_string(10).length, 1);
-    equal(u.random_number_string(100).length, 2);
-    equal(u.random_number_string(1000).length, 3);
-    equal(u.random_number_string(10000).length, 4);
-    equal(u.random_number_string(100000).length, 5);
+    assert.equal(u.random_number_string(10).length, 1);
+    assert.equal(u.random_number_string(100).length, 2);
+    assert.equal(u.random_number_string(1000).length, 3);
+    assert.equal(u.random_number_string(10000).length, 4);
+    assert.equal(u.random_number_string(100000).length, 5);
   }
 });
 
 test('getOrigin', function() {
-  equal(u.getOrigin('http://a.b/'), 'http://a.b:80');
-  equal(u.getOrigin('http://a.b/c'), 'http://a.b:80');
-  equal(u.getOrigin('http://a.b:123/c'), 'http://a.b:123');
-  equal(u.getOrigin('https://a.b/'), 'https://a.b:443');
-  equal(u.getOrigin('file://a.b/'), null);
+  assert.equal(u.getOrigin('http://a.b/'), 'http://a.b:80');
+  assert.equal(u.getOrigin('http://a.b/c'), 'http://a.b:80');
+  assert.equal(u.getOrigin('http://a.b:123/c'), 'http://a.b:123');
+  assert.equal(u.getOrigin('https://a.b/'), 'https://a.b:443');
+  assert.equal(u.getOrigin('file://a.b/'), null);
 });
 
 test('isSameOriginUrl', function() {
-  ok(u.isSameOriginUrl('http://localhost', 'http://localhost/'));
-  ok(u.isSameOriginUrl('http://localhost', 'http://localhost/abc'));
-  ok(u.isSameOriginUrl('http://localhost/', 'http://localhost'));
-  ok(u.isSameOriginUrl('http://localhost', 'http://localhost'));
-  ok(u.isSameOriginUrl('http://localhost', 'http://localhost:8080') === false);
-  ok(u.isSameOriginUrl('http://localhost:8080', 'http://localhost') === false);
-  ok(u.isSameOriginUrl('http://localhost:8080', 'http://localhost:8080/'));
-  ok(u.isSameOriginUrl('http://127.0.0.1:80/', 'http://127.0.0.1:80/a'));
-  ok(u.isSameOriginUrl('http://127.0.0.1:80', 'http://127.0.0.1:80/a'));
-  ok(u.isSameOriginUrl('http://localhost', 'http://localhost:80'));
-  ok(u.isSameOriginUrl('http://127.0.0.1/', 'http://127.0.0.1:80/a'));
-  ok(u.isSameOriginUrl('http://127.0.0.1:9', 'http://127.0.0.1:9999') === false);
-  ok(u.isSameOriginUrl('http://127.0.0.1:99', 'http://127.0.0.1:9999') === false);
-  ok(u.isSameOriginUrl('http://127.0.0.1:999', 'http://127.0.0.1:9999') === false);
-  ok(u.isSameOriginUrl('http://127.0.0.1:9999', 'http://127.0.0.1:9999'));
-  ok(u.isSameOriginUrl('http://127.0.0.1:99999', 'http://127.0.0.1:9999') === false);
+  assert.ok(u.isSameOriginUrl('http://localhost', 'http://localhost/'));
+  assert.ok(u.isSameOriginUrl('http://localhost', 'http://localhost/abc'));
+  assert.ok(u.isSameOriginUrl('http://localhost/', 'http://localhost'));
+  assert.ok(u.isSameOriginUrl('http://localhost', 'http://localhost'));
+  assert.ok(u.isSameOriginUrl('http://localhost', 'http://localhost:8080') === false);
+  assert.ok(u.isSameOriginUrl('http://localhost:8080', 'http://localhost') === false);
+  assert.ok(u.isSameOriginUrl('http://localhost:8080', 'http://localhost:8080/'));
+  assert.ok(u.isSameOriginUrl('http://127.0.0.1:80/', 'http://127.0.0.1:80/a'));
+  assert.ok(u.isSameOriginUrl('http://127.0.0.1:80', 'http://127.0.0.1:80/a'));
+  assert.ok(u.isSameOriginUrl('http://localhost', 'http://localhost:80'));
+  assert.ok(u.isSameOriginUrl('http://127.0.0.1/', 'http://127.0.0.1:80/a'));
+  assert.ok(u.isSameOriginUrl('http://127.0.0.1:9', 'http://127.0.0.1:9999') === false);
+  assert.ok(u.isSameOriginUrl('http://127.0.0.1:99', 'http://127.0.0.1:9999') === false);
+  assert.ok(u.isSameOriginUrl('http://127.0.0.1:999', 'http://127.0.0.1:9999') === false);
+  assert.ok(u.isSameOriginUrl('http://127.0.0.1:9999', 'http://127.0.0.1:9999'));
+  assert.ok(u.isSameOriginUrl('http://127.0.0.1:99999', 'http://127.0.0.1:9999') === false);
 });
 
 test("getParentDomain", function() {
@@ -64,18 +63,18 @@ test("getParentDomain", function() {
     'a2.a3.org': 'a3.org'
   };
   for (k in domains) {
-    equal(u.getParentDomain(k), domains[k]);
+    assert.equal(u.getParentDomain(k), domains[k]);
   }
 });
 
 test('objectExtend', function() {
   var a, b;
-  deepEqual(u.objectExtend({}, {}), {});
+  assert.deepEqual(u.objectExtend({}, {}), {});
   a = {
     a: 1
   };
-  equal(u.objectExtend(a, {}), a);
-  equal(u.objectExtend(a, {
+  assert.equal(u.objectExtend(a, {}), a);
+  assert.equal(u.objectExtend(a, {
     b: 1
   }), a);
   a = {
@@ -84,15 +83,15 @@ test('objectExtend', function() {
   b = {
     b: 2
   };
-  deepEqual(u.objectExtend(a, b), {
+  assert.deepEqual(u.objectExtend(a, b), {
     a: 1,
     b: 2
   });
-  deepEqual(a, {
+  assert.deepEqual(a, {
     a: 1,
     b: 2
   });
-  deepEqual(b, {
+  assert.deepEqual(b, {
     b: 2
   });
 });
@@ -103,70 +102,70 @@ test('bind', function() {
   fun = function() {
     return this;
   };
-  deepEqual(fun(), undefined);
+  assert.deepEqual(fun(), undefined);
   bound_fun = u.bind(fun, o);
-  deepEqual(bound_fun(), o);
+  assert.deepEqual(bound_fun(), o);
 });
 
 test('amendUrl', function() {
   var dl, t;
   dl = document.location;
-  equal(u.amendUrl('//blah:1/abc'), dl.protocol + '//blah:1/abc');
-  equal(u.amendUrl('/abc'), dl.protocol + '//' + dl.host + '/abc');
-  equal(u.amendUrl('/'), dl.protocol + '//' + dl.host);
-  equal(u.amendUrl('http://a:1/abc'), 'http://a:1/abc');
-  equal(u.amendUrl('http://a:1/abc/'), 'http://a:1/abc');
-  equal(u.amendUrl('http://a:1/abc//'), 'http://a:1/abc');
+  assert.equal(u.amendUrl('//blah:1/abc'), dl.protocol + '//blah:1/abc');
+  assert.equal(u.amendUrl('/abc'), dl.protocol + '//' + dl.host + '/abc');
+  assert.equal(u.amendUrl('/'), dl.protocol + '//' + dl.host);
+  assert.equal(u.amendUrl('http://a:1/abc'), 'http://a:1/abc');
+  assert.equal(u.amendUrl('http://a:1/abc/'), 'http://a:1/abc');
+  assert.equal(u.amendUrl('http://a:1/abc//'), 'http://a:1/abc');
   t = function() {
     return u.amendUrl('');
   };
-  raises(t, 'Wrong url');
+  assert.throws(t, 'Wrong url');
   t = function() {
     return u.amendUrl(false);
   };
-  raises(t, 'Wrong url');
+  assert.throws(t, 'Wrong url');
   t = function() {
     return u.amendUrl('http://abc?a=a');
   };
-  raises(t, 'Only basic urls are supported');
+  assert.throws(t, 'Only basic urls are supported');
   t = function() {
     return u.amendUrl('http://abc#a');
   };
-  raises(t, 'Only basic urls are supported');
-  equal(u.amendUrl('http://a:80/abc'), 'http://a/abc');
-  equal(u.amendUrl('https://a:443/abc'), 'https://a/abc');
-  equal(u.amendUrl('https://a:80/abc'), 'https://a:80/abc');
-  equal(u.amendUrl('http://a:443/abc'), 'http://a:443/abc');
+  assert.throws(t, 'Only basic urls are supported');
+  assert.equal(u.amendUrl('http://a:80/abc'), 'http://a/abc');
+  assert.equal(u.amendUrl('https://a:443/abc'), 'https://a/abc');
+  assert.equal(u.amendUrl('https://a:80/abc'), 'https://a:80/abc');
+  assert.equal(u.amendUrl('http://a:443/abc'), 'http://a:443/abc');
 });
 
 test('arrIndexOf', function() {
   var a;
   a = [1, 2, 3, 4, 5];
-  equal(u.arrIndexOf(a, 1), 0);
-  equal(u.arrIndexOf(a, 5), 4);
-  equal(u.arrIndexOf(a, null), -1);
-  equal(u.arrIndexOf(a, 6), -1);
+  assert.equal(u.arrIndexOf(a, 1), 0);
+  assert.equal(u.arrIndexOf(a, 5), 4);
+  assert.equal(u.arrIndexOf(a, null), -1);
+  assert.equal(u.arrIndexOf(a, 6), -1);
 });
 
 test('arrSkip', function() {
   var a;
   a = [1, 2, 3, 4, 5];
-  deepEqual(u.arrSkip(a, 1), [2, 3, 4, 5]);
-  deepEqual(u.arrSkip(a, 2), [1, 3, 4, 5]);
-  deepEqual(u.arrSkip(a, 11), [1, 2, 3, 4, 5]);
-  deepEqual(u.arrSkip(a, 'a'), [1, 2, 3, 4, 5]);
-  deepEqual(u.arrSkip(a, '1'), [1, 2, 3, 4, 5]);
+  assert.deepEqual(u.arrSkip(a, 1), [2, 3, 4, 5]);
+  assert.deepEqual(u.arrSkip(a, 2), [1, 3, 4, 5]);
+  assert.deepEqual(u.arrSkip(a, 11), [1, 2, 3, 4, 5]);
+  assert.deepEqual(u.arrSkip(a, 'a'), [1, 2, 3, 4, 5]);
+  assert.deepEqual(u.arrSkip(a, '1'), [1, 2, 3, 4, 5]);
 });
 
 test('quote', function() {
   var all_chars, c, i;
-  equal(u.quote(''), '""');
-  equal(u.quote('a'), '"a"');
-  ok(u.arrIndexOf(['"\\t"', '"\\u0009"'], u.quote('\t')) !== -1);
-  ok(u.arrIndexOf(['"\\n"', '"\\u000a"'], u.quote('\n')) !== -1);
-  equal(u.quote('\x00\udfff\ufffe\uffff'), '"\\u0000\\udfff\\ufffe\\uffff"');
-  equal(u.quote('\ud85c\udff7\ud800\ud8ff'), '"\\ud85c\\udff7\\ud800\\ud8ff"');
-  equal(u.quote('\u2000\u2001\u0300\u0301'), '"\\u2000\\u2001\\u0300\\u0301"');
+  assert.equal(u.quote(''), '""');
+  assert.equal(u.quote('a'), '"a"');
+  assert.ok(u.arrIndexOf(['"\\t"', '"\\u0009"'], u.quote('\t')) !== -1);
+  assert.ok(u.arrIndexOf(['"\\n"', '"\\u000a"'], u.quote('\n')) !== -1);
+  assert.equal(u.quote('\x00\udfff\ufffe\uffff'), '"\\u0000\\udfff\\ufffe\\uffff"');
+  assert.equal(u.quote('\ud85c\udff7\ud800\ud8ff'), '"\\ud85c\\udff7\\ud800\\ud8ff"');
+  assert.equal(u.quote('\u2000\u2001\u0300\u0301'), '"\\u2000\\u2001\\u0300\\u0301"');
   c = (function() {
     var _results;
     _results = [];
@@ -176,7 +175,7 @@ test('quote', function() {
     return _results;
   })();
   all_chars = c.join('');
-  ok(JSON.parse(u.quote(all_chars)) === all_chars, "Quote/unquote all 64K chars.");
+  assert.ok(JSON.parse(u.quote(all_chars)) === all_chars, "Quote/unquote all 64K chars.");
 });
 
 test('detectProtocols', function() {
@@ -192,8 +191,8 @@ test('detectProtocols', function() {
     'iframe-xhr-polling': true,
     'jsonp-polling': true
   };
-  deepEqual(u.detectProtocols(chrome_probed, null, {}), ['websocket', 'xhr-streaming', 'xhr-polling']);
-  deepEqual(u.detectProtocols(chrome_probed, null, {
+  assert.deepEqual(u.detectProtocols(chrome_probed, null, {}), ['websocket', 'xhr-streaming', 'xhr-polling']);
+  assert.deepEqual(u.detectProtocols(chrome_probed, null, {
     websocket: false
   }), ['xhr-streaming', 'xhr-polling']);
   opera_probed = {
@@ -207,7 +206,7 @@ test('detectProtocols', function() {
     'iframe-xhr-polling': true,
     'jsonp-polling': true
   };
-  deepEqual(u.detectProtocols(opera_probed, null, {}), ['iframe-eventsource', 'iframe-xhr-polling']);
+  assert.deepEqual(u.detectProtocols(opera_probed, null, {}), ['iframe-eventsource', 'iframe-xhr-polling']);
   ie6_probed = {
     'websocket': false,
     'xdr-streaming': false,
@@ -219,7 +218,7 @@ test('detectProtocols', function() {
     'iframe-xhr-polling': false,
     'jsonp-polling': true
   };
-  deepEqual(u.detectProtocols(ie6_probed, null, {}), ['jsonp-polling']);
+  assert.deepEqual(u.detectProtocols(ie6_probed, null, {}), ['jsonp-polling']);
   ie8_probed = {
     'websocket': false,
     'xdr-streaming': true,
@@ -231,8 +230,8 @@ test('detectProtocols', function() {
     'iframe-xhr-polling': true,
     'jsonp-polling': true
   };
-  deepEqual(u.detectProtocols(ie8_probed, null, {}), ['xdr-streaming', 'xdr-polling']);
-  deepEqual(u.detectProtocols(ie8_probed, null, {
+  assert.deepEqual(u.detectProtocols(ie8_probed, null, {}), ['xdr-streaming', 'xdr-polling']);
+  assert.deepEqual(u.detectProtocols(ie8_probed, null, {
     cookie_needed: true
   }), ['iframe-htmlfile', 'iframe-xhr-polling']);
   ie10_probed = {
@@ -246,54 +245,53 @@ test('detectProtocols', function() {
     'iframe-xhr-polling': true,
     'jsonp-polling': true
   };
-  deepEqual(u.detectProtocols(ie10_probed, null, {}), ['websocket', 'xhr-streaming', 'xhr-polling']);
-  deepEqual(u.detectProtocols(ie10_probed, null, {
+  assert.deepEqual(u.detectProtocols(ie10_probed, null, {}), ['websocket', 'xhr-streaming', 'xhr-polling']);
+  assert.deepEqual(u.detectProtocols(ie10_probed, null, {
     cookie_needed: true
   }), ['websocket', 'xhr-streaming', 'xhr-polling']);
-  deepEqual(u.detectProtocols(chrome_probed, null, {
+  assert.deepEqual(u.detectProtocols(chrome_probed, null, {
     null_origin: true
   }), ['websocket', 'iframe-eventsource', 'iframe-xhr-polling']);
-  deepEqual(u.detectProtocols(chrome_probed, null, {
+  assert.deepEqual(u.detectProtocols(chrome_probed, null, {
     websocket: false,
     null_origin: true
   }), ['iframe-eventsource', 'iframe-xhr-polling']);
-  deepEqual(u.detectProtocols(opera_probed, null, {
+  assert.deepEqual(u.detectProtocols(opera_probed, null, {
     null_origin: true
   }), ['iframe-eventsource', 'iframe-xhr-polling']);
-  deepEqual(u.detectProtocols(ie6_probed, null, {
+  assert.deepEqual(u.detectProtocols(ie6_probed, null, {
     null_origin: true
   }), ['jsonp-polling']);
-  deepEqual(u.detectProtocols(ie8_probed, null, {
+  assert.deepEqual(u.detectProtocols(ie8_probed, null, {
     null_origin: true
   }), ['iframe-htmlfile', 'iframe-xhr-polling']);
-  deepEqual(u.detectProtocols(ie10_probed, null, {
+  assert.deepEqual(u.detectProtocols(ie10_probed, null, {
     null_origin: true
   }), ['websocket', 'iframe-htmlfile', 'iframe-xhr-polling']);
 });
 
 test("EventEmitter", function() {
   var bluff, handler0, handler1, handler2, handler3, handler4, log, r, single;
-  expect(7);
   r = new SockJS('//1.2.3.4/wrongurl', null, {
     protocols_whitelist: []
   });
   r.addEventListener('message', function() {
-    return ok(true);
+    return assert.ok(true);
   });
   r.onmessage = function() {
-    return ok(false);
+    return assert.ok(false);
   };
   bluff = function() {
-    return ok(false);
+    return assert.ok(false);
   };
   r.addEventListener('message', bluff);
   r.removeEventListener('message', bluff);
   r.addEventListener('message', bluff);
   r.addEventListener('message', function() {
-    return ok(true);
+    return assert.ok(true);
   });
   r.onmessage = function() {
-    return ok(true);
+    return assert.ok(true);
   };
   r.removeEventListener('message', bluff);
   r.dispatchEvent({
@@ -328,19 +326,19 @@ test("EventEmitter", function() {
   r.dispatchEvent({
     type: 'test'
   });
-  deepEqual(log, [0, 1, 2]);
+  assert.deepEqual(log, [0, 1, 2]);
   log = [];
   r.dispatchEvent({
     type: 'test'
   });
-  deepEqual(log, [1, 3, 4]);
+  assert.deepEqual(log, [1, 3, 4]);
   log = [];
   r.dispatchEvent({
     type: 'test'
   });
-  deepEqual(log, []);
+  assert.deepEqual(log, []);
   single = function() {
-    return ok(true);
+    return assert.ok(true);
   };
   r.addEventListener('close', single);
   r.addEventListener('close', single);
@@ -356,15 +354,15 @@ test("EventEmitter", function() {
 
 test("NoConstructor", function() {
   var r;
-  expect(2);
   r = new SockJS('//1.2.3.4/blah', null, {
     protocols_whitelist: []
   });
-  ok(r instanceof SockJS);
+  assert.ok(r instanceof SockJS);
   r.close();
+  /* jshint newcap: false */
   r = SockJS('//1.2.3.4/blah', null, {
     protocols_whitelist: []
   });
-  ok(r instanceof SockJS);
+  assert.ok(r instanceof SockJS);
   r.close();
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list