[Pkg-javascript-commits] [sockjs-client] 326/350: Fix linting

tonnerre at ancient-solutions.com tonnerre at ancient-solutions.com
Fri Aug 5 01:04:35 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 0b4879d5e0b7f44d9f8accb28759fd965f70ea1f
Author: Bryce Kahle <bkahle at gmail.com>
Date:   Sun Aug 2 01:50:35 2015 -0700

    Fix linting
---
 gulpfile.js                           |   9 ++-
 lib/event/event.js                    |   6 +-
 lib/main.js                           |   2 +-
 lib/transport/browser/abstract-xhr.js |  16 +++-
 lib/transport/iframe.js               |   4 +-
 lib/transport/lib/ajax-based.js       |   2 +-
 lib/transport/receiver/htmlfile.js    |   4 +-
 lib/transport/receiver/jsonp.js       |   8 +-
 lib/transport/sender/xdr.js           |   4 +-
 lib/utils/iframe.js                   |  14 +++-
 lib/version.js                        |   2 +-
 package.json                          |   3 +-
 tests/browser.js                      |   2 +
 tests/lib/batch-tests.js              |  16 ++--
 tests/lib/echo-tests.js               |  24 +++---
 tests/lib/end-to-end.js               |  16 ++--
 tests/lib/iframe.js                   |   4 +-
 tests/lib/senders.js                  |   3 +-
 tests/lib/test-utils.js               |  14 ++--
 tests/lib/transports.js               | 136 +++++++++++++++++-----------------
 tests/support/sockjs_app.js           |  18 ++---
 tests/support/sockjs_server.js        |   2 +-
 22 files changed, 174 insertions(+), 135 deletions(-)

diff --git a/gulpfile.js b/gulpfile.js
index 0585c11..6a525ff 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -37,7 +37,12 @@ gulp.task('test', function () {
 });
 
 gulp.task('eslint', function () {
-  gulp.src(['lib/**/*.js'])
+  gulp.src([
+      'lib/**/*.js',
+      'tests/lib/**/*.js',
+      'tests/support/**/*.js',
+      'tests/*.js'
+    ])
     .pipe(eslint())
     .pipe(eslint.format());
 });
@@ -47,7 +52,7 @@ gulp.task('watch', function () {
 });
 
 gulp.task('write-version', function () {
-  fs.writeFileSync('./lib/version.js', "module.exports = '" + pkg.version + "';");
+  fs.writeFileSync('./lib/version.js', "module.exports = '" + pkg.version + "';\n");
 });
 
 gulp.task('testbundle', ['browserify:min'], function() {
diff --git a/lib/event/event.js b/lib/event/event.js
index 0d451de..dfb3544 100644
--- a/lib/event/event.js
+++ b/lib/event/event.js
@@ -13,10 +13,10 @@ Event.prototype.initEvent = function(eventType, canBubble, cancelable) {
 };
 
 Event.prototype.stopPropagation = function() {};
-Event.prototype.preventDefault  = function() {};
+Event.prototype.preventDefault = function() {};
 
 Event.CAPTURING_PHASE = 1;
-Event.AT_TARGET       = 2;
-Event.BUBBLING_PHASE  = 3;
+Event.AT_TARGET = 2;
+Event.BUBBLING_PHASE = 3;
 
 module.exports = Event;
diff --git a/lib/main.js b/lib/main.js
index 6c69fc8..165d9bf 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -59,7 +59,7 @@ function SockJS(url, protocols, options) {
       return random.string(sessionId);
     };
   } else {
-    throw new TypeError("If sessionId is used in the options, it needs to be a number or a function.");
+    throw new TypeError('If sessionId is used in the options, it needs to be a number or a function.');
   }
 
   this._server = options.server || random.numberString(1000);
diff --git a/lib/transport/browser/abstract-xhr.js b/lib/transport/browser/abstract-xhr.js
index 08a0a1a..b3716e8 100644
--- a/lib/transport/browser/abstract-xhr.js
+++ b/lib/transport/browser/abstract-xhr.js
@@ -29,7 +29,9 @@ AbstractXHRObject.prototype._start = function(method, url, payload, opts) {
 
   try {
     this.xhr = new XHR();
-  } catch (x) {}
+  } catch (x) {
+    // intentionally empty
+  }
 
   if (!this.xhr) {
     debug('no xhr');
@@ -90,7 +92,9 @@ AbstractXHRObject.prototype._start = function(method, url, payload, opts) {
         try {
           status = x.status;
           text = x.responseText;
-        } catch (e) {}
+        } catch (e) {
+          // intentionally empty
+        }
         debug('status', status);
         // IE returns 1223 for 204: http://bugs.jquery.com/ticket/1450
         if (status === 1223) {
@@ -149,7 +153,9 @@ AbstractXHRObject.prototype._cleanup = function(abort) {
   if (abort) {
     try {
       this.xhr.abort();
-    } catch (x) {}
+    } catch (x) {
+      // intentionally empty
+    }
   }
   this.unloadRef = this.xhr = null;
 };
@@ -178,7 +184,9 @@ if (!AbstractXHRObject.enabled && (axo in global)) {
 var cors = false;
 try {
   cors = 'withCredentials' in new XHR();
-} catch (ignored) {}
+} catch (ignored) {
+  // intentionally empty
+}
 
 AbstractXHRObject.supportsCORS = cors;
 
diff --git a/lib/transport/iframe.js b/lib/transport/iframe.js
index fdf734d..a674794 100644
--- a/lib/transport/iframe.js
+++ b/lib/transport/iframe.js
@@ -60,7 +60,9 @@ IframeTransport.prototype.close = function() {
       // When the iframe is not loaded, IE raises an exception
       // on 'contentWindow'.
       this.postMessage('c');
-    } catch (x) {}
+    } catch (x) {
+      // intentionally empty
+    }
     this.iframeObj.cleanup();
     this.iframeObj = null;
     this.onmessageCallback = this.iframeObj = null;
diff --git a/lib/transport/lib/ajax-based.js b/lib/transport/lib/ajax-based.js
index 6477fbc..29e104e 100644
--- a/lib/transport/lib/ajax-based.js
+++ b/lib/transport/lib/ajax-based.js
@@ -15,7 +15,7 @@ function createAjaxSender(AjaxObject) {
     debug('create ajax sender', url, payload);
     var opt = {};
     if (typeof payload === 'string') {
-      opt.headers = {'Content-type':'text/plain'};
+      opt.headers = {'Content-type': 'text/plain'};
     }
     var ajaxUrl = urlUtils.addPath(url, '/xhr_send');
     var xo = new AjaxObject('POST', ajaxUrl, payload, opt);
diff --git a/lib/transport/receiver/htmlfile.js b/lib/transport/receiver/htmlfile.js
index a560c55..3885031 100644
--- a/lib/transport/receiver/htmlfile.js
+++ b/lib/transport/receiver/htmlfile.js
@@ -77,7 +77,9 @@ var axo = ['Active'].concat('Object').join('X');
 if (axo in global) {
   try {
     HtmlfileReceiver.htmlfileEnabled = !!new global[axo]('htmlfile');
-  } catch (x) {}
+  } catch (x) {
+    // intentionally empty
+  }
 }
 
 HtmlfileReceiver.enabled = HtmlfileReceiver.htmlfileEnabled || iframeUtils.iframeEnabled;
diff --git a/lib/transport/receiver/jsonp.js b/lib/transport/receiver/jsonp.js
index 99cf992..365fecc 100644
--- a/lib/transport/receiver/jsonp.js
+++ b/lib/transport/receiver/jsonp.js
@@ -130,7 +130,9 @@ JsonpReceiver.prototype._createScript = function(url) {
         try {
           // In IE, actually execute the script.
           script.onclick();
-        } catch (x) {}
+        } catch (x) {
+          // intentionally empty
+        }
       }
       if (script) {
         self._abort(new Error('JSONP script loaded abnormally (onreadystatechange)'));
@@ -156,7 +158,9 @@ JsonpReceiver.prototype._createScript = function(url) {
       try {
         script.htmlFor = script.id;
         script.event = 'onclick';
-      } catch (x) {}
+      } catch (x) {
+        // intentionally empty
+      }
       script.async = true;
     } else {
       // Opera, second sync script hack
diff --git a/lib/transport/sender/xdr.js b/lib/transport/sender/xdr.js
index 35d6593..eda6ed4 100644
--- a/lib/transport/sender/xdr.js
+++ b/lib/transport/sender/xdr.js
@@ -85,7 +85,9 @@ XDRObject.prototype._cleanup = function(abort) {
   if (abort) {
     try {
       this.xdr.abort();
-    } catch (x) {}
+    } catch (x) {
+      // intentionally empty
+    }
   }
   this.unloadRef = this.xdr = null;
 };
diff --git a/lib/utils/iframe.js b/lib/utils/iframe.js
index bfe7884..77ea7c7 100644
--- a/lib/utils/iframe.js
+++ b/lib/utils/iframe.js
@@ -41,7 +41,9 @@ module.exports = {
       // Explorer had problems with that.
       try {
         iframe.onload = null;
-      } catch (x) {}
+      } catch (x) {
+        // intentionally empty
+      }
       iframe.onerror = null;
     };
     var cleanup = function() {
@@ -77,7 +79,9 @@ module.exports = {
             iframe.contentWindow.postMessage(msg, origin);
           }
         }, 0);
-      } catch (x) {}
+      } catch (x) {
+        // intentionally empty
+      }
     };
 
     iframe.src = iframeUrl;
@@ -127,7 +131,7 @@ module.exports = {
         CollectGarbage();
       }
     };
-    var onerror = function(r)  {
+    var onerror = function(r) {
       debug('onerror', r);
       if (doc) {
         cleanup();
@@ -143,7 +147,9 @@ module.exports = {
               iframe.contentWindow.postMessage(msg, origin);
           }
         }, 0);
-      } catch (x) {}
+      } catch (x) {
+        // intentionally empty
+      }
     };
 
     doc.open();
diff --git a/lib/version.js b/lib/version.js
index d0fc015..29abc80 100644
--- a/lib/version.js
+++ b/lib/version.js
@@ -1 +1 @@
-module.exports = '1.0.3';
\ No newline at end of file
+module.exports = '1.0.3';
diff --git a/package.json b/package.json
index b0f501f..ea5431d 100644
--- a/package.json
+++ b/package.json
@@ -65,6 +65,7 @@
     "test": "make test",
     "test_local": "zuul --local 9090 -- tests/browser.js",
     "zuul": "zuul -- tests/browser.js",
-    "gulp": "gulp"
+    "gulp": "gulp",
+    "lint": "gulp eslint"
   }
 }
diff --git a/tests/browser.js b/tests/browser.js
index c0d9d5d..7a71f74 100644
--- a/tests/browser.js
+++ b/tests/browser.js
@@ -4,7 +4,9 @@ require('../lib/shims');
 
 // prevent global leak warnings on this
 global._jp = {};
+/* eslint-disable camelcase */
 global._sockjs_global = null;
+/* eslint-enable camelcase */
 
 require('./lib/main');
 require('./lib/utils');
diff --git a/tests/lib/batch-tests.js b/tests/lib/batch-tests.js
index e70f9a3..dfbf0db 100644
--- a/tests/lib/batch-tests.js
+++ b/tests/lib/batch-tests.js
@@ -20,8 +20,8 @@ function batchFactory(transport, messages, url) {
     sjs.onmessage = function (e) {
       try {
         expect(e.data).to.eql(messages[counter]);
-      } catch (e) {
-        done(e);
+      } catch (err) {
+        done(err);
         sjs.close();
         return;
       }
@@ -39,8 +39,8 @@ function batchFactory(transport, messages, url) {
       try {
         expect(e.code).to.equal(1000);
         expect(counter).to.equal(messages.length);
-      } catch (e) {
-        done(e);
+      } catch (err) {
+        done(err);
         return;
       }
       done();
@@ -70,8 +70,8 @@ function amplifyFactory(transport, messages, url) {
     sjs.onmessage = function (e) {
       try {
         expect(e.data).to.have.length(Math.pow(2, messages[counter]));
-      } catch (e) {
-        done(e);
+      } catch (err) {
+        done(err);
         sjs.close();
         return;
       }
@@ -88,8 +88,8 @@ function amplifyFactory(transport, messages, url) {
       try {
         expect(e.code).to.equal(1000);
         expect(counter).to.equal(messages.length);
-      } catch (e) {
-        done(e);
+      } catch (err) {
+        done(err);
         return;
       }
 
diff --git a/tests/lib/echo-tests.js b/tests/lib/echo-tests.js
index 5096ab3..6e569df 100644
--- a/tests/lib/echo-tests.js
+++ b/tests/lib/echo-tests.js
@@ -24,8 +24,8 @@ function echoFactory(transport, messages, url) {
       // TODO don't like having to force the element toString here
       try {
         expect(e.data).to.eql('' + msgs[0]);
-      } catch (e) {
-        done(e);
+      } catch (err) {
+        done(err);
         sjs.close();
         return;
       }
@@ -45,8 +45,8 @@ function echoFactory(transport, messages, url) {
       try {
         expect(e.code).to.equal(1000);
         expect(msgs).to.have.length(0);
-      } catch (e) {
-        done(e);
+      } catch (err) {
+        done(err);
         return;
       }
 
@@ -76,6 +76,7 @@ module.exports.echoRich = function echoRich(url, transport) {
   it('echo rich', echoFactory(transport, messages, url + '/echo'));
 };
 
+/* eslint-disable quotes */
 module.exports.echoUnicode = function echoUnicode(url, transport) {
   var messages = ["Τη γλώσσα μου έδωσαν ελληνική το σπίτι φτωχικό στις αμμουδιές του ", "ღმერთსი შემვედრე, ნუთუ კვლა დამხსნას სოფლისა შრომასა, ცეცხლს, წყალს", "⠊⠀⠉⠁⠝⠀⠑⠁⠞⠀⠛⠇⠁⠎⠎⠀⠁⠝⠙⠀⠊⠞⠀⠙⠕⠑⠎⠝⠞⠀⠓⠥⠗⠞⠀⠍⠑", "Би шил идэй чадна, надад хортой биш", "을", "나는 유리를 먹을 수 있어요. 그래도 아프지 않아요", "ฉันกินกระจกได้ แต่มันไม่ทำให้ฉันเจ็บฉันกินกระจกได้ แต่มันไม่ทำให้ฉันเจ็บ", "Ég get etið gler án þess að meiða mig.", "Mogę jeść szkło, i mi nie szkodzi.", "\ufffd\u10102\u2f877", "Начало музыкальной карьеры\nБритни  [...]
   it('unicode', echoFactory(transport, messages, url + '/echo'));
@@ -85,6 +86,7 @@ module.exports.echoSpecialChars = function echoSpecialChars(url, transport) {
   var messages = [" ", "\u0000", "\xff", "\xff\x00", "\x00\xff", " \r ", " \n ", " \r\n ", "\r\n", "", "message\t", "\tmessage", "message ", " message", "message\r", "\rmessage", "message\n", "\nmessage", "message\xff", "\xffmessage", "A", "b", "c", "d", "e", "\ufffd", "\ufffd\u0000", "message\ufffd", "\ufffdmessage"];
   it('special chars', echoFactory(transport, messages, url + '/echo'));
 };
+/* eslint-enable quotes */
 
 module.exports.echoLargeMessage = function echoLargeMessage(url, transport) {
   var 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')];
@@ -136,7 +138,9 @@ module.exports.echoFromChild = function echoFromChild(url, transport) {
       i++;
       hookReady = true;
       hook.sjs = sjs;
-      sockJsReady && hook.callback(code);
+      if (sockJsReady) {
+        hook.callback(code);
+      }
     };
     hook.onsend = function () {
       debug('hook onsend');
@@ -152,7 +156,9 @@ module.exports.echoFromChild = function echoFromChild(url, transport) {
       hook.iobj.loaded();
       i++;
       sockJsReady = true;
-      hookReady && hook.callback(code);
+      if (hookReady) {
+        hook.callback(code);
+      }
     };
     sjs.onmessage = function(e) {
       debug('hook sjs message, e.data');
@@ -160,8 +166,8 @@ module.exports.echoFromChild = function echoFromChild(url, transport) {
       try {
         expect(e.data).to.equal('a');
         expect(i).to.equal(2);
-      } catch (e) {
-        done(e);
+      } catch (err) {
+        done(err);
       } finally {
         hook.iobj.cleanup();
         hook.del();
@@ -175,7 +181,7 @@ module.exports.echoFromChild = function echoFromChild(url, transport) {
 
       try {
         expect(e.code).to.equal(1000);
-      } catch (e) {
+      } catch (err) {
         done(e);
         return;
       }
diff --git a/tests/lib/end-to-end.js b/tests/lib/end-to-end.js
index 544f518..7b4a4df 100644
--- a/tests/lib/end-to-end.js
+++ b/tests/lib/end-to-end.js
@@ -29,8 +29,8 @@ describe('End to End', function () {
           expect(e.code).to.equal(1002);
           expect(e.reason).to.equal('Cannot connect to server');
           expect(e.wasClean).to.equal(false);
-        } catch (e) {
-          done(e);
+        } catch (err) {
+          done(err);
           return;
         }
 
@@ -68,8 +68,8 @@ describe('End to End', function () {
             expect(e.code).to.equal(1002);
             expect(e.reason).to.equal('Cannot connect to server');
             expect(e.wasClean).to.equal(false);
-          } catch (e) {
-            done(e);
+          } catch (err) {
+            done(err);
             return;
           }
 
@@ -95,8 +95,8 @@ describe('End to End', function () {
           expect(e.code).to.equal(2000);
           expect(e.reason).to.equal('All transports failed');
           expect(e.wasClean).to.equal(false);
-        } catch (e) {
-          done(e);
+        } catch (err) {
+          done(err);
           return;
         }
         done();
@@ -123,8 +123,8 @@ describe('End to End', function () {
           expect(e.code).to.equal(3000);
           expect(e.reason).to.equal('Go away!');
           expect(e.wasClean).to.equal(true);
-        } catch (e) {
-          done(e);
+        } catch (err) {
+          done(err);
           return;
         }
 
diff --git a/tests/lib/iframe.js b/tests/lib/iframe.js
index 3105949..6217541 100644
--- a/tests/lib/iframe.js
+++ b/tests/lib/iframe.js
@@ -106,8 +106,8 @@ describe('iframe', function () {
           case 'e':
             try {
               expect(i).to.equal(2);
-            } catch (e) {
-              done(e);
+            } catch (err) {
+              done(err);
               hook.iobj.cleanup();
               hook.del();
               return;
diff --git a/tests/lib/senders.js b/tests/lib/senders.js
index 75085f3..1d17ed9 100644
--- a/tests/lib/senders.js
+++ b/tests/lib/senders.js
@@ -9,7 +9,6 @@ var expect = require('expect.js')
 
 function ajaxSimple (Obj) {
   it('simple', function (done) {
-    var test = this.runnable();
     var x = new Obj('GET', testUtils.getSameOriginUrl() + '/simple.txt', null);
     x.on('finish', function (status, text) {
       try {
@@ -34,7 +33,7 @@ function ajaxStreaming (Obj) {
     var test = this.runnable();
     var x = new Obj('GET', testUtils.getSameOriginUrl() + '/streaming.txt', null);
     var i = 0;
-    x.on('chunk', function (status, text) {
+    x.on('chunk', function (status/*, text*/) {
       try {
         expect(status).to.equal(200);
       } catch (e) {
diff --git a/tests/lib/test-utils.js b/tests/lib/test-utils.js
index 3a9d886..f4174be 100644
--- a/tests/lib/test-utils.js
+++ b/tests/lib/test-utils.js
@@ -37,14 +37,16 @@ module.exports = {
     var windowId = 'a' + random.string(8);
     if (!global[MPrefix]) {
       var map = {};
-      global[MPrefix] = function(windowId) {
-        if (!(windowId in map)) {
-          map[windowId] = {
-            id: windowId,
-            del: function() {delete map[windowId];}
+      global[MPrefix] = function(id) {
+        if (!(id in map)) {
+          map[id] = {
+            id: id,
+            del: function() {
+              delete map[id];
+            }
           };
         }
-        return map[windowId];
+        return map[id];
       };
     }
     return global[MPrefix](windowId);
diff --git a/tests/lib/transports.js b/tests/lib/transports.js
index ca44544..44610da 100644
--- a/tests/lib/transports.js
+++ b/tests/lib/transports.js
@@ -9,70 +9,6 @@ var expect = require('expect.js')
   , SockJS = require('../../lib/entry')
   ;
 
-describe('Transports', function () {
-  transportList.forEach(function (Trans) {
-    describe(Trans.transportName, function () {
-      it('has a valid interface', function () {
-        expect(Trans).to.be.ok();
-        expect(Trans).to.have.property('transportName');
-        expect(Trans.transportName.length).to.be.greaterThan(0);
-
-        expect(Trans).to.have.property('roundTrips');
-        expect(Trans.roundTrips).to.be.a('number');
-
-        expect(Trans).to.have.property('enabled');
-        expect(Trans.enabled).to.be.a('function');
-
-        expect(Trans.prototype).to.have.property('send');
-        expect(Trans.prototype.send).to.be.a('function');
-
-        expect(Trans.prototype).to.have.property('close');
-        expect(Trans.prototype.close).to.be.a('function');
-
-        //var t = new Trans('http://localhost');
-        //expect(t).to.be.an(EventEmitter);
-        // TODO tests for event emitting
-      });
-
-      if (!Trans.enabled({ cookie_needed: false, nullOrigin: false, sameScheme: true, sameOrigin: true })) {
-        it('[unsupported]');
-        return;
-      }
-
-      var transport = Trans.transportName;
-
-      var soUrl = testUtils.getSameOriginUrl();
-      describe('same origin', function () {
-        runTests(soUrl, transport);
-      });
-
-      // var corsUrl = testUtils.getCrossOriginUrl();
-      // if (corsUrl && corsUrl !== soUrl) {
-      //   describe('cross origin', function () {
-      //     runTests(corsUrl, transport);
-      //   });
-      // }
-    });
-  });
-});
-
-function runTests(url, transport) {
-  echoTests.echoBasic(url, transport);
-  echoTests.echoQueryString(url, transport);
-  echoTests.echoRich(url, transport);
-  echoTests.echoUnicode(url, transport);
-  echoTests.echoSpecialChars(url, transport);
-  echoTests.echoLargeMessage(url, transport);
-  echoTests.echoUtfEncodingSimple(url, transport);
-  echoTests.echoUtfEncoding(url, transport);
-
-  batchTests.largeMessage(url, transport);
-  batchTests.largeDownload(url, transport);
-
-  userClose(url, transport);
-  serverClose(url, transport);
-}
-
 function userClose(url, transport) {
   it('user close', function (done) {
     var test = this.runnable();
@@ -105,8 +41,8 @@ function userClose(url, transport) {
       try {
         expect(e.wasClean).to.equal(true);
         expect(counter).to.equal(2);
-      } catch (e) {
-        done(e);
+      } catch (err) {
+        done(err);
         return;
       }
 
@@ -139,11 +75,75 @@ function serverClose(url, transport) {
         expect(e.code).to.equal(3000);
         expect(e.reason).to.equal('Go away!');
         expect(e.wasClean).to.equal(true);
-      } catch (e) {
-        done(e);
+      } catch (err) {
+        done(err);
         return;
       }
       done();
     };
   });
 }
+
+function runTests(url, transport) {
+  echoTests.echoBasic(url, transport);
+  echoTests.echoQueryString(url, transport);
+  echoTests.echoRich(url, transport);
+  echoTests.echoUnicode(url, transport);
+  echoTests.echoSpecialChars(url, transport);
+  echoTests.echoLargeMessage(url, transport);
+  echoTests.echoUtfEncodingSimple(url, transport);
+  echoTests.echoUtfEncoding(url, transport);
+
+  batchTests.largeMessage(url, transport);
+  batchTests.largeDownload(url, transport);
+
+  userClose(url, transport);
+  serverClose(url, transport);
+}
+
+describe('Transports', function () {
+  transportList.forEach(function (Trans) {
+    describe(Trans.transportName, function () {
+      it('has a valid interface', function () {
+        expect(Trans).to.be.ok();
+        expect(Trans).to.have.property('transportName');
+        expect(Trans.transportName.length).to.be.greaterThan(0);
+
+        expect(Trans).to.have.property('roundTrips');
+        expect(Trans.roundTrips).to.be.a('number');
+
+        expect(Trans).to.have.property('enabled');
+        expect(Trans.enabled).to.be.a('function');
+
+        expect(Trans.prototype).to.have.property('send');
+        expect(Trans.prototype.send).to.be.a('function');
+
+        expect(Trans.prototype).to.have.property('close');
+        expect(Trans.prototype.close).to.be.a('function');
+
+        //var t = new Trans('http://localhost');
+        //expect(t).to.be.an(EventEmitter);
+        // TODO tests for event emitting
+      });
+
+      if (!Trans.enabled({ cookie_needed: false, nullOrigin: false, sameScheme: true, sameOrigin: true })) {
+        it('[unsupported]');
+        return;
+      }
+
+      var transport = Trans.transportName;
+
+      var soUrl = testUtils.getSameOriginUrl();
+      describe('same origin', function () {
+        runTests(soUrl, transport);
+      });
+
+      // var corsUrl = testUtils.getCrossOriginUrl();
+      // if (corsUrl && corsUrl !== soUrl) {
+      //   describe('cross origin', function () {
+      //     runTests(corsUrl, transport);
+      //   });
+      // }
+    });
+  });
+});
diff --git a/tests/support/sockjs_app.js b/tests/support/sockjs_app.js
index 29be47e..894ce54 100644
--- a/tests/support/sockjs_app.js
+++ b/tests/support/sockjs_app.js
@@ -11,9 +11,9 @@ exports.install = function(opts, server) {
       debug('    [-] echo close   ' + conn);
     });
     conn.on('data', function(m) {
-      var d  = JSON.stringify(m);
+      var d = JSON.stringify(m);
       debug('    [ ] echo message ' + conn,
-                  d.slice(0,64) +
+                  d.slice(0, 64) +
                   ((d.length > 64) ? '...' : ''));
       conn.write(m);
     });
@@ -75,14 +75,14 @@ exports.install = function(opts, server) {
   });
 
 
-  sjs_echo.installHandlers(server, {prefix:'/echo',
+  sjs_echo.installHandlers(server, {prefix: '/echo',
                                     response_limit: 4096});
-  sjs_echo.installHandlers(server, {prefix:'/disabled_websocket_echo',
+  sjs_echo.installHandlers(server, {prefix: '/disabled_websocket_echo',
                                     websocket: false});
-  sjs_echo.installHandlers(server, {prefix:'/cookie_needed_echo',
+  sjs_echo.installHandlers(server, {prefix: '/cookie_needed_echo',
                                     jsessionid: true});
-  sjs_close.installHandlers(server, {prefix:'/close'});
-  sjs_ticker.installHandlers(server, {prefix:'/ticker'});
-  sjs_amplify.installHandlers(server, {prefix:'/amplify'});
-  sjs_broadcast.installHandlers(server, {prefix:'/broadcast'});
+  sjs_close.installHandlers(server, {prefix: '/close'});
+  sjs_ticker.installHandlers(server, {prefix: '/ticker'});
+  sjs_amplify.installHandlers(server, {prefix: '/amplify'});
+  sjs_broadcast.installHandlers(server, {prefix: '/broadcast'});
 };
diff --git a/tests/support/sockjs_server.js b/tests/support/sockjs_server.js
index e835809..7749860 100644
--- a/tests/support/sockjs_server.js
+++ b/tests/support/sockjs_server.js
@@ -14,7 +14,7 @@ var clientOptions = {
   url: 'http://localhost:' + port,
   sockjs_opts: {
       // websocket:false
-      info: {cookie_needed:false}
+      info: {cookie_needed: false}
   }
 };
 

-- 
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