-// requires local modules: websock, util
-// requires test modules: fake.websocket, assertions
-/* jshint expr: true */
-var assert = chai.assert;
var expect = chai.expect;
+import Websock from '../core/websock.js';
+import FakeWebSocket from './fake.websocket.js';
+
+import sinon from '../vendor/sinon.js';
+
describe('Websock', function() {
"use strict";
var sock;
beforeEach(function () {
- sock = new Websock();
- WebSocket = sinon.spy();
- WebSocket.OPEN = old_WS.OPEN;
- WebSocket.CONNECTING = old_WS.CONNECTING;
- WebSocket.CLOSING = old_WS.CLOSING;
- WebSocket.CLOSED = old_WS.CLOSED;
-
- WebSocket.prototype.binaryType = 'arraybuffer';
+ sock = new Websock();
+ // eslint-disable-next-line no-global-assign
+ WebSocket = sinon.spy();
+ WebSocket.OPEN = old_WS.OPEN;
+ WebSocket.CONNECTING = old_WS.CONNECTING;
+ WebSocket.CLOSING = old_WS.CLOSING;
+ WebSocket.CLOSED = old_WS.CLOSED;
+
+ WebSocket.prototype.binaryType = 'arraybuffer';
});
describe('opening', function () {
});
after(function () {
+ // eslint-disable-next-line no-global-assign
WebSocket = old_WS;
});
});
expect(sock.get_rQi()).to.equal(0);
expect(sock._rQ.length).to.equal(240); // keep the invariant that rQbufferSize / 8 >= rQlen
});
-
- it('should call the error event handler on an exception', function () {
- sock._eventHandlers.error = sinon.spy();
- sock._eventHandlers.message = sinon.stub().throws();
- var msg = { data: new Uint8Array([1, 2, 3]).buffer };
- sock._mode = 'binary';
- sock._recv_message(msg);
- expect(sock._eventHandlers.error).to.have.been.calledOnce;
- });
});
describe('Data encoding', function () {