Permalink
Browse files

test: fix syntax, remove globals

  • Loading branch information...
1 parent 1f02fcf commit 8ede274e05e849991f5ab0703ac4c49c4cb8f07f @rauchg rauchg committed Jan 5, 2014
Showing with 44 additions and 45 deletions.
  1. +0 −1 Makefile
  2. +4 −22 test/common.js
  3. +6 −3 test/engine.io.js
  4. +28 −17 test/jsonp.js
  5. +6 −2 test/server.js
View
@@ -5,7 +5,6 @@ REPORTER = dot
test:
@./node_modules/.bin/mocha \
- --require test/common \
--reporter $(REPORTER) \
--slow 500ms \
--bail \
View
@@ -1,39 +1,21 @@
/**
- * Expose `eio` global.
+ * Module dependencies.
*/
-global.eio = require('../index');
-
-/**
- * Expose client.
- */
-
-global.eioc = require('engine.io-client');
-
-/**
- * Expose `request` global.
- */
-
-global.request = require('superagent');
-
-/**
- * Expose `expect` global
- */
-
-global.expect = require('expect.js');
+var eio = require('..');
/**
* Listen shortcut that fires a callback on an epheemal port.
*/
-global.listen = function (opts, fn) {
+exports.listen = function (opts, fn) {
if ('function' == typeof opts) {
fn = opts;
opts = {};
}
- var e = global.eio.listen(null, opts, function () {
+ var e = eio.listen(null, opts, function () {
fn(e.httpServer.address().port);
});
View
@@ -1,11 +1,14 @@
-/*global eio,listen,request,expect*/
/**
* Test dependencies.
*/
-var net = require('net')
- , http = require('http');
+var net = require('net');
+var eio = require('..');
+var listen = require('./common').listen;
+var expect = require('expect.js');
+var request = require('superagent');
+var http = require('http');
/**
* Tests.
View
@@ -1,17 +1,24 @@
-/*global eio,eioc,listen,request,expect*/
+
+/**
+ * Module dependencies.
+ */
var http = require('http');
+var eioc = require('engine.io-client');
+var listen = require('./common').listen;
+var expect = require('expect.js');
+var request = require('superagent');
var WebSocket = require('ws');
describe('JSONP', function () {
before(function () {
// we have to override the browser's functionality for JSONP
document = {
body: {
- appendChild: function () {}
- , removeChild: function () {}
+ appendChild: function(){},
+ removeChild: function(){}
}
- }
+ };
document.createElement = function (name) {
var self = this;
@@ -31,16 +38,20 @@ describe('JSONP', function () {
return script;
} else if ('form' == name) {
var form = {
- style: {}
- , action: ''
- , parentNode: { removeChild: function () {} }
- , removeChild: function () {}
- , setAttribute: function () {}
- , appendChild: function (elem) { area: elem; }
- , submit: function () {
- request.post(this.action).type('form').send({ d: self.areaValue }).end(function (res) {});
- }
- }
+ style: {},
+ action: '',
+ parentNode: { removeChild: function(){} },
+ removeChild: function(){},
+ setAttribute: function(){},
+ appendChild: function(){},
+ submit: function(){
+ request
+ .post(this.action)
+ .type('form')
+ .send({ d: self.areaValue })
+ .end(function(){});
+ }
+ };
return form;
} else if ('textarea' == name) {
var textarea = {};
@@ -134,9 +145,9 @@ describe('JSONP', function () {
it('should trigger when client closes', function (done) {
var engine = listen( { allowUpgrades: false, transports: ['polling'] }, function (port) {
- var socket = new eioc.Socket('ws://localhost:' + port
- , { transports: ['polling'], forceJSONP: true, upgrade: false })
- , total = 2;
+ var socket = new eioc.Socket('ws://localhost:' + port
+ , { transports: ['polling'], forceJSONP: true, upgrade: false })
+ , total = 2;
engine.on('connection', function (conn) {
conn.on('close', function (reason) {
View
@@ -1,10 +1,14 @@
-/*global eio,eioc,listen,request,expect*/
/**
* Tests dependencies.
*/
var http = require('http');
+var eio = require('..');
+var eioc = require('engine.io-client');
+var listen = require('./common').listen;
+var expect = require('expect.js');
+var request = require('superagent');
var WebSocket = require('ws');
/**
@@ -683,7 +687,7 @@ describe('server', function () {
expect(clientCloseReason).to.be(null);
}, 350);
setTimeout(function() {
- expect(clientCloseReason).to.be("ping timeout");
+ expect(clientCloseReason).to.be('ping timeout');
done();
}, 500);
});

0 comments on commit 8ede274

Please sign in to comment.