Skip to content

Commit

Permalink
adding tests for engine.io-client socketio#207, PR socketio#239
Browse files Browse the repository at this point in the history
  • Loading branch information
mokesmokes2 committed Feb 2, 2014
1 parent 461918b commit 9bf3119
Showing 1 changed file with 58 additions and 7 deletions.
65 changes: 58 additions & 7 deletions test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,21 +695,72 @@ describe('server', function () {
});
});

// tests https://github.com/LearnBoost/engine.io-client/issues/164
it('should not trigger close without open', function(done){
var opts = { allowUpgrades: false };
// tests https://github.com/LearnBoost/engine.io-client/issues/207
// websocket test, transport error
it('should trigger transport close before open for ws', function(done){
var opts = { transports: ['websocket'] };
var engine = listen(opts, function (port) {
var socket = new eioc.Socket('ws://invalidserver:%d'.s(port));
socket.on('open', function(){
done(new Error('Test invalidation'));
});
socket.on('close', function(reason){
expect(reason).to.be('transport error');
done();
});
});
});

// tests https://github.com/LearnBoost/engine.io-client/issues/207
// polling test, transport error
it('should trigger transport close before open for xhr', function(done){
var opts = { transports: ['polling'] };
var engine = listen(opts, function (port) {
var socket = new eioc.Socket('http://invalidserver:%d'.s(port));
socket.on('open', function(){
done(new Error('Test invalidation'));
});
socket.on('close', function(reason){
expect(reason).to.be('transport error');
done();
});
});
});

// tests https://github.com/LearnBoost/engine.io-client/issues/207
// websocket test, force close
it('should trigger force close before open for ws', function(done){
var opts = { transports: ['websocket'] };
var engine = listen(opts, function (port) {
var socket = new eioc.Socket('ws://localhost:%d'.s(port));
socket.on('open', function(){
done(new Error('Test invalidation'));
});
socket.on('close', function(reason){
expect(reason).to.be('forced close');
done();
});
socket.close();
});
});

// tests https://github.com/LearnBoost/engine.io-client/issues/207
// polling test, force close
it('should trigger force close before open for xhr', function(done){
var opts = { transports: ['polling'] };
var engine = listen(opts, function (port) {
var socket = new eioc.Socket('http://localhost:%d'.s(port));
socket.on('open', function(){
throw new Error('Nope');
done(new Error('Test invalidation'));
});
socket.on('close', function(){
throw new Error('Nope');
socket.on('close', function(reason){
expect(reason).to.be('forced close');
done();
});
setTimeout(done, 100);
socket.close();
});
});

});

describe('messages', function () {
Expand Down

0 comments on commit 9bf3119

Please sign in to comment.