mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
Added client close test.
This commit is contained in:
@@ -266,6 +266,31 @@ describe('server', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should trigger when client closes', function (done) {
|
||||
var engine = eio.listen(4000, { allowUpgrades: false }, function () {
|
||||
var socket = new eioc.Socket('ws://localhost:4000')
|
||||
, total = 2
|
||||
|
||||
engine.on('connection', function (conn) {
|
||||
conn.on('close', function (reason) {
|
||||
expect(reason).to.be('transport close');
|
||||
--total || engine.httpServer.once('close', done).close();
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('open', function () {
|
||||
socket.on('close', function (reason) {
|
||||
expect(reason).to.be('forced close');
|
||||
--total || engine.httpServer.once('close', done).close();
|
||||
});
|
||||
|
||||
setTimeout(function () {
|
||||
socket.close();
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user