Skip to content

Commit

Permalink
Add disconnect from namespace test-case for issue socketio#795
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Baulig committed Mar 19, 2012
1 parent e7d7582 commit da95094
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/namespace.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,5 +282,46 @@ module.exports = {
}
});
});
},
'disconnecting from namespace only': function (done) {
var cl = client(++ports)
, io = create(cl)
, ws1
, ws2;

io.of('/foo').on('connection', function (socket) {
socket.disconnect();
});

cl.handshake(function (sid) {
ws1 = websocket(cl, sid);
ws1.on('open', function () {
ws1.packet({
type: 'connect'
, endpoint: '/bar'
});
cl.handshake(function (sid) {
ws2 = websocket(cl, sid);
ws2.on('open', function () {
ws2.packet({
type: 'connect'
, endpoint: '/foo'
});
});
ws2.on('message', function (data) {
if ('disconnect' === data.type) {
cl.end();
ws1.finishClose();
ws2.finishClose();
io.server.close();

data.endpoint.should.eql('/foo');

done();
}
});
});
});
});
}
};

0 comments on commit da95094

Please sign in to comment.