From a46cfe529fdab7a1003244a19da378f31518ef38 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Thu, 26 Mar 2015 13:03:15 -0700 Subject: [PATCH] added tests for pintTimeout --- package.json | 2 +- test/unit/specs/client.js | 4 ++-- test/unit/specs/connection_abstract.js | 13 +++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 60cafeb98..0a5bf8ae6 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "./src/lib/loggers/index.js": "./src/lib/loggers/browser_index.js", "./src/lib/apis/index.js": "./src/lib/apis/browser_index.js", "./test/mocks/server.js": "./test/mocks/browser_server.js", - "lodash": "./node_modules/lodash/dist/lodash.compat.js" + "lodash": "./node_modules/lodash-compat/index.js" }, "config": { "blanket": { diff --git a/test/unit/specs/client.js b/test/unit/specs/client.js index 2e9aa135e..d208532b2 100644 --- a/test/unit/specs/client.js +++ b/test/unit/specs/client.js @@ -54,11 +54,11 @@ describe('Client instances creation', function () { }); describe('#ping', function () { - it('sets the default requestTimeout to 100', function () { + it('sets the default requestTimeout to 3000', function () { stub(client.transport, 'request'); client.ping(); expect(client.transport.request.callCount).to.be(1); - expect(client.transport.request.lastCall.args[0].requestTimeout).to.be(100); + expect(client.transport.request.lastCall.args[0].requestTimeout).to.be(3000); }); }); }); diff --git a/test/unit/specs/connection_abstract.js b/test/unit/specs/connection_abstract.js index 27ac5c1bd..a1e8ec88b 100644 --- a/test/unit/specs/connection_abstract.js +++ b/test/unit/specs/connection_abstract.js @@ -66,6 +66,19 @@ describe('Connection Abstract', function () { expect(conn.request.lastCall.args[1]).to.be.a('function'); }); + it('defaults to the pingTimeout in the config', function () { + var conn = new ConnectionAbstract(host, { pingTimeout: 5000 }); + var clock = sinon.useFakeTimers('setTimeout', 'clearTimeout'); + stub.autoRelease(clock); + + stub(conn, 'request'); + + expect(_.size(clock.timers)).to.eql(0); + conn.ping(); + expect(_.size(clock.timers)).to.eql(1); + expect(clock.timers[_.keys(clock.timers).shift()].delay).to.eql(5000); + }); + it('calls it\'s own request method', function () { var conn = new ConnectionAbstract(host); var football = {};