spec/javascripts/generated/specs/websocket_connection_spec.js in websocket-rails-0.4.8 vs spec/javascripts/generated/specs/websocket_connection_spec.js in websocket-rails-0.4.9
- old
+ new
@@ -79,34 +79,46 @@
this.connection.on_message(event);
return mock_dispatcher.verify();
});
});
describe('.on_close', function() {
- return it('should dispatch the connection_closed event and pass the original event', function() {
+ it('should dispatch the connection_closed event and pass the original event', function() {
var close_event, dispatcher, event, lastCall;
event = new WebSocketRails.Event(['event', 'message']);
close_event = new WebSocketRails.Event(['connection_closed', event]);
sinon.spy(this.dispatcher, 'dispatch');
- this.connection.on_close(event);
+ this.connection.on_close(close_event);
dispatcher = this.dispatcher.dispatch;
lastCall = dispatcher.lastCall.args[0];
expect(dispatcher.calledOnce).toBe(true);
expect(lastCall.data).toEqual(event.data);
return dispatcher.restore();
});
+ return it('sets the connection state on the dispatcher to disconnected', function() {
+ var close_event;
+ close_event = new WebSocketRails.Event(['connection_closed', {}]);
+ this.connection.on_close(close_event);
+ return expect(this.dispatcher.state).toEqual('disconnected');
+ });
});
describe('.on_error', function() {
- return it('should dispatch the connection_error event and pass the original event', function() {
+ it('should dispatch the connection_error event and pass the original event', function() {
var dispatcher, error_event, event, lastCall;
event = new WebSocketRails.Event(['event', 'message']);
error_event = new WebSocketRails.Event(['connection_error', event]);
sinon.spy(this.dispatcher, 'dispatch');
this.connection.on_error(event);
dispatcher = this.dispatcher.dispatch;
lastCall = dispatcher.lastCall.args[0];
expect(dispatcher.calledOnce).toBe(true);
expect(lastCall.data).toEqual(event.data);
return dispatcher.restore();
+ });
+ return it('sets the connection state on the dispatcher to disconnected', function() {
+ var close_event;
+ close_event = new WebSocketRails.Event(['connection_closed', {}]);
+ this.connection.on_error(close_event);
+ return expect(this.dispatcher.state).toEqual('disconnected');
});
});
return describe('.flush_queue', function() {
beforeEach(function() {
this.event = new WebSocketRails.Event(['event', 'message']);