]> git.proxmox.com Git - mirror_novnc.git/blobdiff - tests/test.websock.js
Add eslint and fix reported issues
[mirror_novnc.git] / tests / test.websock.js
index 023c7726811d861aad8b03baa3999fc3e7845889..1e978ec23ebdc1eac3a3f6060e32b71b11c3b42d 100644 (file)
@@ -1,9 +1,10 @@
-// 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";
 
@@ -229,14 +230,15 @@ describe('Websock', function() {
 
         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 () {
@@ -325,6 +327,7 @@ describe('Websock', function() {
         });
 
         after(function () {
+            // eslint-disable-next-line no-global-assign
             WebSocket = old_WS;
         });
     });
@@ -386,15 +389,6 @@ describe('Websock', function() {
             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 () {