Commit 4d4b0986 by Ben Drucker

Use a one minute timeout for streaming requests

parent bec93073
......@@ -56,6 +56,7 @@ ClearbitClient.prototype.request = function (options) {
webhook_id: options.webhook_id
}, options.query),
{
timeout: options.stream ? 60000 : 5000,
username: this.key,
user_agent: 'ClearbitNode/v' + pkg.version
}
......
......@@ -2,6 +2,8 @@
var expect = require('chai').expect;
var nock = require('nock');
var sinon = require('sinon');
var needle = require('needle');
var clearbit = require('../');
var Client = clearbit.Client;
var pkg = require('../package.json');
......@@ -98,6 +100,21 @@ describe('Client', function () {
});
});
it('uses a timeout of 60 seconds for streaming requests', function () {
sinon.stub(needle, 'request').yieldsAsync(null, {}, undefined);
return client.request({
api: 'person',
stream: true
})
.then(function () {
expect(needle.request.firstCall.args[3])
.to.have.property('timeout', 60000);
})
.finally(function () {
needle.request.restore();
})
});
it('sends a basic auth header', function () {
mock
.get('/v1/people/email/bvdrucker@gmail.com')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment