and finally, return to standard mo

This commit is contained in:
spalger
2016-05-19 14:33:04 -07:00
parent ec06c51c5d
commit 8ad271d81c
74 changed files with 594 additions and 597 deletions

View File

@ -4,7 +4,7 @@ var errors = require('../../../src/lib/errors');
var sinon = require('sinon');
var expect = require('expect.js');
// var _ = require('lodash');
var _ = require('lodash');
var nodeList = require('../../fixtures/short_node_list.json');
var stub = require('../../utils/auto_release_stub').make();
@ -83,11 +83,11 @@ describe('Transport Class', function () {
sniffInterval: 25000
});
expect(_v4.size(clock.timers)).to.eql(1);
var id = _v4.keys(clock.timers).pop();
expect(_.size(clock.timers)).to.eql(1);
var id = _.keys(clock.timers).pop();
clock.tick(25000);
expect(trans.sniff.callCount).to.eql(1);
expect(_v4.size(clock.timers)).to.eql(1);
expect(_.size(clock.timers)).to.eql(1);
expect(clock.timers).to.not.have.key(id);
});
@ -285,25 +285,25 @@ describe('Transport Class', function () {
describe('randomizeHosts options', function () {
it('calls _.shuffle be default', function () {
// var _ = require('../../../src/lib/utils');
var _ = require('../../../src/lib/utils');
stub(Transport.connectionPools.main.prototype, 'setHosts');
stub(_v4, 'shuffle');
stub(_, 'shuffle');
var trans = new Transport({
hosts: 'localhost'
});
expect(_v4.shuffle.callCount).to.eql(1);
expect(_.shuffle.callCount).to.eql(1);
});
it('skips the call to _.shuffle when false', function () {
// var _ = require('../../../src/lib/utils');
var _ = require('../../../src/lib/utils');
stub(Transport.connectionPools.main.prototype, 'setHosts');
stub(_v4, 'shuffle');
stub(_, 'shuffle');
var trans = new Transport({
hosts: 'localhost',
randomizeHosts: false
});
expect(_v4.shuffle.callCount).to.eql(0);
expect(_.shuffle.callCount).to.eql(0);
});
});
});
@ -606,7 +606,7 @@ describe('Transport Class', function () {
}
var trans = new Transport({
hosts: _v4.map(new Array(retries + 1), function (val, i) {
hosts: _.map(new Array(retries + 1), function (val, i) {
return 'localhost/' + i;
}),
maxRetries: retries,
@ -617,8 +617,8 @@ describe('Transport Class', function () {
});
// trigger a select so that we can harvest the connection list
trans.connectionPool.select(_v4.noop);
_v4.each(connections, function (conn) {
trans.connectionPool.select(_.noop);
_.each(connections, function (conn) {
stub(conn, 'request', failRequest);
});
@ -632,7 +632,7 @@ describe('Transport Class', function () {
});
};
}
it('retries when there are retries remaining', testRetries(_v4.random(25, 40)));
it('retries when there are retries remaining', testRetries(_.random(25, 40)));
it('responds when there are no retries', testRetries(0));
});
@ -641,7 +641,7 @@ describe('Transport Class', function () {
it('returns an object with an abort() method when a callback is sent', function () {
var tran = new Transport();
shortCircuitRequest(tran);
var ret = tran.request({}, _v4.noop);
var ret = tran.request({}, _.noop);
expect(ret).to.be.a('object');
expect(ret.abort).to.be.a('function');
});
@ -651,7 +651,7 @@ describe('Transport Class', function () {
var ret = tran.request({});
expect(ret.then).to.be.a('function');
expect(ret.abort).to.be.a('function');
ret.then(_v4.noop, _v4.noop); // prevent complaining from bluebird
ret.then(_.noop, _.noop); // prevent complaining from bluebird
});
it('promise is always pulled from the defer created by this.defer()', function () {
var fakePromise = {};
@ -659,8 +659,8 @@ describe('Transport Class', function () {
var tran = new Transport({
defer: function () {
return {
resolve: _v4.noop,
reject: _v4.noop,
resolve: _.noop,
reject: _.noop,
promise: fakePromise
};
}
@ -759,10 +759,10 @@ describe('Transport Class', function () {
var prom = tran.request({});
// disregard promise, prevent bluebird's warnings
prom.then(_v4.noop, _v4.noop);
prom.then(_.noop, _.noop);
expect(_v4.size(clock.timers)).to.eql(1);
_v4.each(clock.timers, function (timer, id) {
expect(_.size(clock.timers)).to.eql(1);
_.each(clock.timers, function (timer, id) {
expect(timer.callAt).to.eql(30000);
clearTimeout(id);
});
@ -776,17 +776,17 @@ describe('Transport Class', function () {
var prom = tran.request({});
// disregard promise, prevent bluebird's warnings
prom.then(_v4.noop, _v4.noop);
prom.then(_.noop, _.noop);
expect(_v4.size(clock.timers)).to.eql(1);
_v4.each(clock.timers, function (timer, id) {
expect(_.size(clock.timers)).to.eql(1);
_.each(clock.timers, function (timer, id) {
expect(timer.callAt).to.eql(5000);
clearTimeout(id);
});
});
_v4.each([false, 0, null], function (falsy) {
_.each([false, 0, null], function (falsy) {
it('skips the timeout when it is ' + falsy, function () {
var clock = sinon.useFakeTimers();
stub.autoRelease(clock);
@ -797,7 +797,7 @@ describe('Transport Class', function () {
requestTimeout: falsy
}, function () {});
expect(_v4.size(clock.timers)).to.eql(0);
expect(_.size(clock.timers)).to.eql(0);
});
});
});