Skip to content

Commit

Permalink
Add test for reconnection after server restarts
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Kovanen committed Jan 14, 2015
1 parent ca82c09 commit 0523b65
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions test/socket.io.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ describe('socket.io', function(){
var c1 = client(srv, '/');
var c2 = client(srv, '/abc');
});

it('should be equivalent for "" and "/" on client', function(done){
var srv = http();
var sio = io(srv);
Expand All @@ -471,7 +471,7 @@ describe('socket.io', function(){
});
var c1 = client(srv, '');
});

it('should work with `of` and many sockets', function(done){
var srv = http();
var sio = io(srv);
Expand Down Expand Up @@ -1101,6 +1101,32 @@ describe('socket.io', function(){
});
});
});

it('should be able to emit after server close and restart', function(done){
var srv = http();
var sio = io(srv);

sio.on('connection', function(socket){
socket.on('ev', function(data){
expect(data).to.be('payload');
done();
});
});

srv.listen(function(){
var port = srv.address().port;
var clientSocket = client(srv, { reconnectionAttempts: 10, reconnectionDelay: 100 });
clientSocket.once('connect', function(){
srv.close(function(){
srv.listen(port, function(){
clientSocket.on('reconnect', function(){
clientSocket.emit('ev', 'payload');
});
});
});
});
});
});
});

describe('messaging many', function(){
Expand Down

0 comments on commit 0523b65

Please sign in to comment.