});
describe('#sendCredentials', function () {
- beforeEach(function () { this.clock = sinon.useFakeTimers(); });
- afterEach(function () { this.clock.restore(); });
-
it('should set the rfb credentials properly"', function () {
client.sendCredentials({ password: 'pass' });
expect(client._rfb_credentials).to.deep.equal({ password: 'pass' });
describe('#_updateConnectionState', function () {
var client;
beforeEach(function () {
- this.clock = sinon.useFakeTimers();
client = make_rfb();
});
- afterEach(function () {
- this.clock.restore();
- });
-
it('should clear the disconnect timer if the state is not "disconnecting"', function () {
var spy = sinon.spy();
client._disconnTimer = setTimeout(spy, 50);
describe('#_fail', function () {
var client;
beforeEach(function () {
- this.clock = sinon.useFakeTimers();
client = make_rfb();
client.connect('wss://host:8675');
});
- afterEach(function () {
- this.clock.restore();
- });
-
it('should close the WebSocket connection', function () {
sinon.spy(client._sock, 'close');
client._fail();
describe('disconnecting', function () {
var client;
beforeEach(function () {
- this.clock = sinon.useFakeTimers();
client = make_rfb();
client.connect('wss://host:8675');
});
- afterEach(function () {
- this.clock.restore();
- });
-
it('should force disconnect if we do not call Websock.onclose within the disconnection timeout', function () {
sinon.spy(client, '_updateConnectionState');
client._sock._websocket.close = function () {}; // explicitly don't call onclose
beforeEach(function () {
client = make_rfb();
client.connect('wss://host:8675');
- this.clock = sinon.useFakeTimers();
});
- afterEach(function () { this.clock.restore(); });
-
// message events
it ('should do nothing if we receive an empty message and have nothing in the queue', function () {
client._rfb_connection_state = 'connected';