mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
Added tests and enhanced event propagation
This commit is contained in:
@@ -130,8 +130,9 @@ describe('connection', function() {
|
||||
var socket = manager.socket('/timeout_socket');
|
||||
|
||||
var reconnects = 0;
|
||||
var reconnectCb = function() {
|
||||
var reconnectCb = function(attempts) {
|
||||
reconnects++;
|
||||
expect(attempts).to.be(reconnects);
|
||||
};
|
||||
|
||||
socket.on('reconnect_attempt', reconnectCb);
|
||||
@@ -142,6 +143,20 @@ describe('connection', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should fire error on socket', function(done) {
|
||||
var manager = io.Manager({ reconnection: true });
|
||||
var socket = manager.socket('/timeout_socket');
|
||||
|
||||
socket.on('error', function(reason) {
|
||||
expect(reason).to.eql({ code: 'test' });
|
||||
done();
|
||||
});
|
||||
|
||||
socket.on('connect', function() {
|
||||
manager.engine.onPacket({ type: 'error', data: 'test' });
|
||||
});
|
||||
});
|
||||
|
||||
it('should fire reconnecting (on socket) with attempts number when reconnecting twice', function(done) {
|
||||
var manager = io.Manager({ reconnection: true, timeout: 0, reconnectionAttempts: 2, reconnectionDelay: 10 });
|
||||
var socket = manager.socket('/timeout_socket');
|
||||
|
||||
Reference in New Issue
Block a user