fix test that now uses through2
This commit is contained in:
@ -306,8 +306,17 @@ describe('Transport + Mock server', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('sniffOnConnectionFault', function () {
|
describe('sniffOnConnectionFault', function () {
|
||||||
it('schedules a sniff when sniffOnConnectionFault is set and a connection failes', function (done) {
|
var clock;
|
||||||
var clock = sinon.useFakeTimers('setTimeout');
|
|
||||||
|
beforeEach(function () {
|
||||||
|
clock = sinon.useFakeTimers('setTimeout');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function () {
|
||||||
|
clock.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('schedules a sniff when sniffOnConnectionFault is set and a connection failes', function () {
|
||||||
var serverMock = nock('http://esbox.1.com')
|
var serverMock = nock('http://esbox.1.com')
|
||||||
.get('/')
|
.get('/')
|
||||||
.reply(200, function () {
|
.reply(200, function () {
|
||||||
@ -315,6 +324,10 @@ describe('Transport + Mock server', function () {
|
|||||||
cb(new Error('force error'));
|
cb(new Error('force error'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
str.write('');
|
||||||
|
}, 10);
|
||||||
|
|
||||||
str.setEncoding = function () {}; // force nock's isStream detection
|
str.setEncoding = function () {}; // force nock's isStream detection
|
||||||
return str;
|
return str;
|
||||||
});
|
});
|
||||||
@ -331,19 +344,19 @@ describe('Transport + Mock server', function () {
|
|||||||
|
|
||||||
tran.request({
|
tran.request({
|
||||||
requestTimeout: Infinity
|
requestTimeout: Infinity
|
||||||
}).then(
|
})
|
||||||
_.partial(done, new Error('expected the request to fail')),
|
.then(function () {
|
||||||
function (err) {
|
throw new Error('expected the request to fail');
|
||||||
expect(ConnectionPool.prototype._onConnectionDied.callCount).to.eql(1);
|
})
|
||||||
expect(tran.sniff.callCount).to.eql(0);
|
.catch(function (err) {
|
||||||
expect(_.size(clock.timeouts)).to.eql(1);
|
expect(ConnectionPool.prototype._onConnectionDied.callCount).to.eql(1);
|
||||||
var timeout = _.values(clock.timeouts).pop();
|
expect(tran.sniff.callCount).to.eql(0);
|
||||||
timeout.func();
|
expect(_.size(clock.timeouts)).to.eql(1);
|
||||||
expect(tran.sniff.callCount).to.eql(1);
|
|
||||||
clock.restore();
|
var timeout = _.values(clock.timeouts).pop();
|
||||||
done();
|
timeout.func();
|
||||||
}
|
expect(tran.sniff.callCount).to.eql(1);
|
||||||
);
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user