[ping()] determine ping timeout at runtime (#679)
* [ping()] determine ping timeout at runtime * generate * single line * remove pingTimeout param * [docs] Add note about pingTimeout priority * remove default ping requestTimeout test * add test
This commit is contained in:
committed by
GitHub
parent
3a56e02ae6
commit
277d33715c
@ -81,13 +81,4 @@ describe('Client instances creation', function () {
|
||||
client.transport.log.error(new Error());
|
||||
});
|
||||
});
|
||||
|
||||
describe('#ping', 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(3000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -788,6 +788,28 @@ describe('Transport Class', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('inherits the pingTimeout from the transport', function () {
|
||||
var clock = sinon.useFakeTimers('setTimeout', 'clearTimeout');
|
||||
stub.autoRelease(clock);
|
||||
var tran = new Transport({
|
||||
requestTimeout: 4000,
|
||||
pingTimeout: 5000
|
||||
});
|
||||
|
||||
var prom = tran.request({
|
||||
path: '/',
|
||||
method: 'HEAD'
|
||||
});
|
||||
// disregard promise, prevent bluebird's warnings
|
||||
prom.then(_.noop, _.noop);
|
||||
|
||||
expect(_.size(clock.timers)).to.eql(1);
|
||||
_.each(clock.timers, function (timer, id) {
|
||||
expect(timer.callAt).to.eql(5000);
|
||||
clearTimeout(id);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
_.each([false, 0, null], function (falsy) {
|
||||
it('skips the timeout when it is ' + falsy, function () {
|
||||
|
||||
Reference in New Issue
Block a user