Skip to content

Commit

Permalink
[test] Use npm scripts instead of gulp (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
darrachequesne committed Sep 1, 2017
1 parent 7f63d38 commit fd20b91
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 132 deletions.
3 changes: 0 additions & 3 deletions .gitignore
@@ -1,5 +1,2 @@
node_modules
npm-debug.log
coverage.html
lib-cov/
dist
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -3,7 +3,7 @@ language: node_js
node_js:
- "4"
- "6"
- "7"
- "8"
git:
depth: 1
notifications:
Expand Down
16 changes: 0 additions & 16 deletions Makefile

This file was deleted.

52 changes: 0 additions & 52 deletions gulpfile.js

This file was deleted.

4 changes: 0 additions & 4 deletions index.js

This file was deleted.

10 changes: 1 addition & 9 deletions lib/server.js
Expand Up @@ -91,14 +91,6 @@ Server.errorMessages = {

util.inherits(Server, EventEmitter);

/**
* Hash of open clients.
*
* @api public
*/

Server.prototype.clients;

/**
* Initialize websocket server
*
Expand Down Expand Up @@ -355,7 +347,7 @@ Server.prototype.handleUpgrade = function (req, socket, upgradeHead) {
return;
}

var head = new Buffer(upgradeHead.length);
var head = new Buffer(upgradeHead.length); // eslint-disable-line node/no-deprecated-api
upgradeHead.copy(head);
upgradeHead = null;

Expand Down
1 change: 0 additions & 1 deletion lib/socket.js
Expand Up @@ -91,7 +91,6 @@ Socket.prototype.onPacket = function (packet) {
this.setPingTimeout();

switch (packet.type) {

case 'ping':
debug('got ping');
this.sendPacket('pong');
Expand Down
4 changes: 2 additions & 2 deletions lib/transports/polling.js
Expand Up @@ -136,7 +136,7 @@ Polling.prototype.onDataRequest = function (req, res) {
this.dataReq = req;
this.dataRes = res;

var chunks = isBinary ? new Buffer(0) : '';
var chunks = isBinary ? new Buffer(0) : ''; // eslint-disable-line node/no-deprecated-api
var self = this;

function cleanup () {
Expand All @@ -162,7 +162,7 @@ Polling.prototype.onDataRequest = function (req, res) {
}

if (contentLength > self.maxHttpBufferSize) {
chunks = isBinary ? new Buffer(0) : '';
chunks = isBinary ? new Buffer(0) : ''; // eslint-disable-line node/no-deprecated-api
req.connection.destroy();
}
}
Expand Down
21 changes: 10 additions & 11 deletions package.json
Expand Up @@ -2,7 +2,7 @@
"name": "engine.io",
"version": "3.1.0",
"description": "The realtime engine behind Socket.IO. Provides the foundation of a bidirectional connection between client and server",
"main": "./lib/engine.io",
"main": "lib/engine.io",
"author": "Guillermo Rauch <guillermo@learnboost.com>",
"homepage": "https://github.com/socketio/engine.io",
"contributors": [
Expand Down Expand Up @@ -33,17 +33,16 @@
"cookie": "0.3.1"
},
"devDependencies": {
"babel-eslint": "5.0.0",
"babel-eslint": "^7.2.3",
"babel-preset-es2015": "^6.24.0",
"engine.io-client": "3.1.0",
"eslint-config-standard": "4.4.0",
"eslint-plugin-standard": "1.3.2",
"eslint": "^4.5.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
"expect.js": "^0.3.1",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-eslint": "1.1.1",
"gulp-mocha": "^4.3.0",
"gulp-nsp": "^2.4.1",
"mocha": "^3.2.0",
"s": "0.1.1",
"superagent": "0.15.4"
Expand All @@ -52,14 +51,14 @@
"uws": "~0.14.4"
},
"scripts": {
"test": "gulp test; EIO_WS_ENGINE=ws gulp test;"
"lint": "eslint lib/ test/ *.js",
"test": "npm run lint && mocha && EIO_WS_ENGINE=ws mocha"
},
"repository": {
"type": "git",
"url": "git@github.com:socketio/engine.io.git"
},
"files": [
"index.js",
"lib/"
]
}
14 changes: 7 additions & 7 deletions test/jsonp.js
Expand Up @@ -11,7 +11,7 @@ var request = require('superagent');
describe('JSONP', function () {
before(function () {
// we have to override the browser's functionality for JSONP
document = { // eslint-disable-line no-native-reassign, no-undef
document = { // eslint-disable-line no-global-assign
body: {
appendChild: function () {},
removeChild: function () {}
Expand Down Expand Up @@ -44,10 +44,10 @@ describe('JSONP', function () {
appendChild: function () {},
submit: function () {
request
.post(this.action)
.type('form')
.send({ d: self.areaValue })
.end(function () {});
.post(this.action)
.type('form')
.send({ d: self.areaValue })
.end(function () {});
}
};
return form;
Expand Down Expand Up @@ -156,7 +156,7 @@ describe('JSONP', function () {
});

it('should arrive from server to client and back with binary data (pollingJSONP)', function (done) {
var binaryData = new Buffer(5);
var binaryData = Buffer.allocUnsafe(5);
for (var i = 0; i < 5; i++) binaryData[i] = i;
engine.on('connection', function (conn) {
conn.on('message', function (msg) {
Expand All @@ -178,7 +178,7 @@ describe('JSONP', function () {
it('should trigger when server closes a client', 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 });
{ transports: ['polling'], forceJSONP: true, upgrade: false });
var total = 2;

engine.on('connection', function (conn) {
Expand Down
54 changes: 28 additions & 26 deletions test/server.js
@@ -1,3 +1,4 @@
/* eslint-disable standard/no-callback-literal */

/**
* Tests dependencies.
Expand Down Expand Up @@ -352,18 +353,18 @@ describe('server', function () {
var socket = new eioc.Socket('ws://localhost:%d'.s(port));
socket.on('open', function () {
request.get('http://localhost:%d/engine.io/'.s(port))
.set({ connection: 'close' })
.query({ transport: 'websocket', sid: socket.id })
.end(function (err, res) {
expect(err).to.be(null);
expect(res.status).to.be(400);
expect(res.body.code).to.be(3);
socket.send('echo');
socket.on('message', function (msg) {
expect(msg).to.be('echo');
done();
.set({ connection: 'close' })
.query({ transport: 'websocket', sid: socket.id })
.end(function (err, res) {
expect(err).to.be(null);
expect(res.status).to.be(400);
expect(res.body.code).to.be(3);
socket.send('echo');
socket.on('message', function (msg) {
expect(msg).to.be('echo');
done();
});
});
});
});
});
});
Expand Down Expand Up @@ -1353,7 +1354,7 @@ describe('server', function () {
});

it('should arrive when binary data is sent as Buffer (ws)', function (done) {
var binaryData = new Buffer(5);
var binaryData = Buffer.allocUnsafe(5);
for (var i = 0; i < binaryData.length; i++) {
binaryData.writeInt8(i, i);
}
Expand All @@ -1379,7 +1380,7 @@ describe('server', function () {
});

it('should arrive when binary data sent as Buffer (polling)', function (done) {
var binaryData = new Buffer(5);
var binaryData = Buffer.allocUnsafe(5);
for (var i = 0; i < binaryData.length; i++) {
binaryData.writeInt8(i, i);
}
Expand All @@ -1406,7 +1407,7 @@ describe('server', function () {
});

it('should arrive as ArrayBuffer if requested when binary data sent as Buffer (ws)', function (done) {
var binaryData = new Buffer(5);
var binaryData = Buffer.allocUnsafe(5);
for (var i = 0; i < binaryData.length; i++) {
binaryData.writeInt8(i, i);
}
Expand Down Expand Up @@ -1435,7 +1436,7 @@ describe('server', function () {
});

it('should arrive as ArrayBuffer if requested when binary data sent as Buffer (polling)', function (done) {
var binaryData = new Buffer(5);
var binaryData = Buffer.allocUnsafe(5);
for (var i = 0; i < binaryData.length; i++) {
binaryData.writeInt8(i, i);
}
Expand Down Expand Up @@ -1516,8 +1517,8 @@ describe('server', function () {
var socket = new eioc.Socket('ws://localhost:%d'.s(port), { transports: ['websocket'] });
socket.on('open', function () {
for (var i = 0; i < messageCount; i++) {
// connection.send('message: ' + i); // works
connection.send(messagePayload + '|message: ' + i); // does not work
// connection.send('message: ' + i); // works
connection.send(messagePayload + '|message: ' + i); // does not work
}
var receivedCount = 0;
socket.on('message', function (msg) {
Expand Down Expand Up @@ -1614,7 +1615,8 @@ describe('server', function () {
key: fs.readFileSync('test/fixtures/server.key'),
cert: fs.readFileSync('test/fixtures/server.crt'),
ca: fs.readFileSync('test/fixtures/ca.crt'),
requestCert: true
requestCert: true,
rejectUnauthorized: false
};

var opts = {
Expand Down Expand Up @@ -2309,7 +2311,7 @@ describe('server', function () {
it('should compress by default', function (done) {
var engine = listen({ transports: ['polling'] }, function (port) {
engine.on('connection', function (conn) {
var buf = new Buffer(1024);
var buf = Buffer.allocUnsafe(1024);
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
conn.send(buf);
});
Expand Down Expand Up @@ -2337,7 +2339,7 @@ describe('server', function () {
it('should compress using deflate', function (done) {
var engine = listen({ transports: ['polling'] }, function (port) {
engine.on('connection', function (conn) {
var buf = new Buffer(1024);
var buf = Buffer.allocUnsafe(1024);
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
conn.send(buf);
});
Expand Down Expand Up @@ -2365,7 +2367,7 @@ describe('server', function () {
it('should set threshold', function (done) {
var engine = listen({ transports: ['polling'], httpCompression: { threshold: 0 } }, function (port) {
engine.on('connection', function (conn) {
var buf = new Buffer(10);
var buf = Buffer.allocUnsafe(10);
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
conn.send(buf);
});
Expand All @@ -2390,7 +2392,7 @@ describe('server', function () {
it('should disable compression', function (done) {
var engine = listen({ transports: ['polling'], httpCompression: false }, function (port) {
engine.on('connection', function (conn) {
var buf = new Buffer(1024);
var buf = Buffer.allocUnsafe(1024);
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
conn.send(buf);
});
Expand All @@ -2415,7 +2417,7 @@ describe('server', function () {
it('should disable compression per message', function (done) {
var engine = listen({ transports: ['polling'] }, function (port) {
engine.on('connection', function (conn) {
var buf = new Buffer(1024);
var buf = Buffer.allocUnsafe(1024);
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
conn.send(buf, { compress: false });
});
Expand All @@ -2440,7 +2442,7 @@ describe('server', function () {
it('should not compress when the byte size is below threshold', function (done) {
var engine = listen({ transports: ['polling'] }, function (port) {
engine.on('connection', function (conn) {
var buf = new Buffer(100);
var buf = Buffer.allocUnsafe(100);
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
conn.send(buf);
});
Expand Down Expand Up @@ -2478,7 +2480,7 @@ describe('server', function () {
done();
};

var buf = new Buffer(100);
var buf = Buffer.allocUnsafe(100);
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
conn.send(buf, { compress: true });
});
Expand All @@ -2500,7 +2502,7 @@ describe('server', function () {
done();
};

var buf = new Buffer(100);
var buf = Buffer.allocUnsafe(100);
for (var i = 0; i < buf.length; i++) buf[i] = i % 0xff;
conn.send(buf, { compress: true });
});
Expand Down

0 comments on commit fd20b91

Please sign in to comment.