final sweep, moved everything to _v4
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
var ca = require('../../../src/lib/client_action').factory;
|
||||
var proxy = require('../../../src/lib/client_action').proxyFactory;
|
||||
var expect = require('expect.js');
|
||||
var _ = require('lodash-migrate');
|
||||
// var _ = require('lodash');
|
||||
var Promise = require('bluebird');
|
||||
|
||||
/**
|
||||
@ -45,7 +45,7 @@ function makeClientAction(spec) {
|
||||
};
|
||||
}
|
||||
|
||||
return _.bind(ca(spec), mockClient());
|
||||
return _v4.bind(ca(spec), mockClient());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,7 +55,7 @@ function makeClientAction(spec) {
|
||||
* @return {Function} - the clientActionProxy
|
||||
*/
|
||||
function makeClientActionProxy(fn, spec) {
|
||||
return _.bind(proxy(fn, spec || {}), mockClient());
|
||||
return _v4.bind(proxy(fn, spec || {}), mockClient());
|
||||
}
|
||||
|
||||
|
||||
@ -118,7 +118,7 @@ describe('Client Action runner', function () {
|
||||
|
||||
it('handles passing just the callback', function () {
|
||||
var action = makeClientActionProxy(function (params, cb) {
|
||||
expect(_.isObject(params)).to.be.ok();
|
||||
expect(_v4.isObject(params)).to.be.ok();
|
||||
expect(cb).to.be.a('function');
|
||||
});
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ var ConnectionAbstract = require('../../../src/lib/connection');
|
||||
var Host = require('../../../src/lib/host');
|
||||
var sinon = require('sinon');
|
||||
var expect = require('expect.js');
|
||||
var _ = require('lodash-migrate');
|
||||
// var _ = require('lodash');
|
||||
var errors = require('../../../src/lib/errors');
|
||||
|
||||
var stub = require('../../utils/auto_release_stub').make();
|
||||
@ -73,10 +73,10 @@ describe('Connection Abstract', function () {
|
||||
|
||||
stub(conn, 'request');
|
||||
|
||||
expect(_.size(clock.timers)).to.eql(0);
|
||||
expect(_v4.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);
|
||||
expect(_v4.size(clock.timers)).to.eql(1);
|
||||
expect(clock.timers[_v4.keys(clock.timers).shift()].delay).to.eql(5000);
|
||||
});
|
||||
|
||||
it('calls it\'s own request method', function () {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
var ConnectionPool = require('../../../src/lib/connection_pool');
|
||||
var Host = require('../../../src/lib/host');
|
||||
var ConnectionAbstract = require('../../../src/lib/connection');
|
||||
var _ = require('lodash-migrate');
|
||||
// var _ = require('lodash');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var expect = require('expect.js');
|
||||
var sinon = require('sinon');
|
||||
@ -36,10 +36,10 @@ describe('Connection Pool', function () {
|
||||
});
|
||||
|
||||
it('#addConnection only adds the connection if it doesn\'t already exist', function () {
|
||||
expect(_.keys(pool.index).length).to.eql(0);
|
||||
expect(_v4.keys(pool.index).length).to.eql(0);
|
||||
pool.addConnection(connection);
|
||||
|
||||
expect(_.keys(pool.index)).to.eql([host.toString()]);
|
||||
expect(_v4.keys(pool.index)).to.eql([host.toString()]);
|
||||
|
||||
expect(pool._conns.alive).to.eql([connection]);
|
||||
expect(pool._conns.dead).to.eql([]);
|
||||
@ -52,7 +52,7 @@ describe('Connection Pool', function () {
|
||||
|
||||
expect(pool._conns.alive).to.eql([connection]);
|
||||
expect(pool._conns.dead).to.eql([]);
|
||||
expect(_.keys(pool.index).length).to.eql(1);
|
||||
expect(_v4.keys(pool.index).length).to.eql(1);
|
||||
});
|
||||
|
||||
it('closes the connection when it removes it', function () {
|
||||
@ -247,13 +247,13 @@ describe('Connection Pool', function () {
|
||||
stub.autoRelease(clock);
|
||||
|
||||
connection.setStatus('dead');
|
||||
expect(_.size(clock.timers)).to.eql(1);
|
||||
var id = _(clock.timers).keys().first();
|
||||
expect(_v4.size(clock.timers)).to.eql(1);
|
||||
var id = _v4(clock.timers).keys().first();
|
||||
|
||||
// it re-dies
|
||||
connection.setStatus('dead');
|
||||
expect(_.size(clock.timers)).to.eql(1);
|
||||
expect(_(clock.timers).keys().first()).to.not.eql(id);
|
||||
expect(_v4.size(clock.timers)).to.eql(1);
|
||||
expect(_v4(clock.timers).keys().first()).to.not.eql(id);
|
||||
});
|
||||
|
||||
it('does nothing when a connection is re-alive', function () {
|
||||
@ -295,7 +295,7 @@ describe('Connection Pool', function () {
|
||||
|
||||
var result = pool.getConnections();
|
||||
expect(result.length).to.be(1000);
|
||||
expect(_.reduce(result, function (sum, num) {
|
||||
expect(_v4.reduce(result, function (sum, num) {
|
||||
sum += num
|
||||
return sum;
|
||||
}, 0)).to.eql(499500);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
var errors = require('../../../src/lib/errors');
|
||||
var expect = require('expect.js');
|
||||
var _ = require('lodash-migrate');
|
||||
// var _ = require('lodash');
|
||||
|
||||
_v4.each(errors, function (CustomError, name) {
|
||||
if (name.charAt(0) !== '_') {
|
||||
|
||||
@ -2,7 +2,7 @@ describe('File Logger', function () {
|
||||
var Log = require('../../../src/lib/log');
|
||||
var FileLogger = require('../../../src/lib/loggers/file');
|
||||
var once = require('events').EventEmitter.prototype.once;
|
||||
var _ = require('../../../src/lib/utils');
|
||||
// var _ = require('../../../src/lib/utils');
|
||||
var parentLog;
|
||||
var logger;
|
||||
var expect = require('expect.js');
|
||||
@ -15,7 +15,7 @@ describe('File Logger', function () {
|
||||
|
||||
afterEach(function () {
|
||||
parentLog.close();
|
||||
logger && _.clearWriteStreamBuffer(logger.stream);
|
||||
logger && _v4.clearWriteStreamBuffer(logger.stream);
|
||||
});
|
||||
|
||||
function makeLogger(parent, levels) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var Host = require('../../../src/lib/host');
|
||||
var _ = require('lodash-migrate');
|
||||
// var _ = require('lodash');
|
||||
var expect = require('expect.js');
|
||||
var url = require('url');
|
||||
var expectSubObject = require('../../utils/expect_sub_object');
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
describe('Http Connector', function () {
|
||||
|
||||
var _ = require('lodash-migrate');
|
||||
// var _ = require('lodash');
|
||||
var expect = require('expect.js');
|
||||
var nock = require('nock');
|
||||
var sinon = require('sinon');
|
||||
@ -67,12 +67,12 @@ describe('Http Connector', function () {
|
||||
|
||||
it('allows defining a custom agent', function () {
|
||||
var football = {};
|
||||
var con = new HttpConnection(new Host(), { createNodeAgent: _.constant(football) });
|
||||
var con = new HttpConnection(new Host(), { createNodeAgent: _v4.constant(football) });
|
||||
expect(con.agent).to.be(football);
|
||||
});
|
||||
|
||||
it('allows setting agent to false', function () {
|
||||
var con = new HttpConnection(new Host(), { createNodeAgent: _.constant(false) });
|
||||
var con = new HttpConnection(new Host(), { createNodeAgent: _v4.constant(false) });
|
||||
expect(con.agent).to.be(false);
|
||||
});
|
||||
});
|
||||
@ -482,7 +482,7 @@ describe('Http Connector', function () {
|
||||
this.timeout(5 * 60 * 1000);
|
||||
var cp = require('child_process');
|
||||
var path = require('path');
|
||||
var fixture = _.partial(path.join, __dirname, '../../fixtures');
|
||||
var fixture = _v4.partial(path.join, __dirname, '../../fixtures');
|
||||
var timeout; // start the timeout once we hear back from the client
|
||||
|
||||
var server = cp.fork(fixture('keepalive_server.js'))
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var Log = require('../../../src/lib/log');
|
||||
var _ = require('lodash-migrate');
|
||||
// var _ = require('lodash');
|
||||
var expect = require('expect.js');
|
||||
|
||||
describe('Log class', function () {
|
||||
@ -129,11 +129,11 @@ describe('Log class', function () {
|
||||
log: [
|
||||
{
|
||||
type: function (log, config) {
|
||||
log.on('error', _.noop);
|
||||
log.on('warning', _.noop);
|
||||
log.on('info', _.noop);
|
||||
log.on('debug', _.noop);
|
||||
log.on('trace', _.noop);
|
||||
log.on('error', _v4.noop);
|
||||
log.on('warning', _v4.noop);
|
||||
log.on('info', _v4.noop);
|
||||
log.on('debug', _v4.noop);
|
||||
log.on('trace', _v4.noop);
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
describe('Random Selector', function () {
|
||||
var randomSelector = require('../../../src/lib/selectors/random');
|
||||
var _ = require('lodash-migrate');
|
||||
// var _ = require('lodash');
|
||||
var expect = require('expect.js');
|
||||
|
||||
it('chooses a selection by random', function () {
|
||||
var log = { a: 0, b: 0, c: 0 };
|
||||
var choices = _.keys(log);
|
||||
var choices = _v4.keys(log);
|
||||
|
||||
_v4.times(1000, function () {
|
||||
var choice = randomSelector(choices);
|
||||
log[choice]++;
|
||||
});
|
||||
|
||||
expect(_.filter(log, function (count) {
|
||||
expect(_v4.filter(log, function (count) {
|
||||
return count < 200 || count > 400;
|
||||
})).to.have.length(0);
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
describe('Round Robin Selector', function () {
|
||||
var selector = require('../../../src/lib/selectors/round_robin');
|
||||
var _ = require('lodash-migrate');
|
||||
// var _ = require('lodash');
|
||||
var expect = require('expect.js');
|
||||
|
||||
it('chooses options in order', function () {
|
||||
|
||||
@ -4,7 +4,7 @@ describe('Stream Logger', function () {
|
||||
var MockWritableStream = require('../../mocks/writable_stream');
|
||||
var once = require('events').EventEmitter.prototype.once;
|
||||
var stream = new MockWritableStream();
|
||||
var _ = require('../../../src/lib/utils');
|
||||
// var _ = require('../../../src/lib/utils');
|
||||
var expect = require('expect.js');
|
||||
var parentLog;
|
||||
|
||||
@ -19,7 +19,7 @@ describe('Stream Logger', function () {
|
||||
|
||||
afterEach(function () {
|
||||
parentLog.close();
|
||||
_.clearWriteStreamBuffer(stream);
|
||||
_v4.clearWriteStreamBuffer(stream);
|
||||
});
|
||||
|
||||
function makeLogger(parent, levels) {
|
||||
@ -41,7 +41,7 @@ describe('Stream Logger', function () {
|
||||
|
||||
// get the last handler for process's "exit" event
|
||||
var exitHandlers = process._events.exit;
|
||||
var exitHandler = _.isArray(exitHandlers) ? _.last(exitHandlers) : exitHandlers;
|
||||
var exitHandler = _v4.isArray(exitHandlers) ? _v4.last(exitHandlers) : exitHandlers;
|
||||
|
||||
// allow the logger to acctually write to the stream
|
||||
stream.write.restore();
|
||||
|
||||
@ -4,7 +4,7 @@ var errors = require('../../../src/lib/errors');
|
||||
|
||||
var sinon = require('sinon');
|
||||
var expect = require('expect.js');
|
||||
var _ = require('lodash-migrate');
|
||||
// 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(_.size(clock.timers)).to.eql(1);
|
||||
var id = _.keys(clock.timers).pop();
|
||||
expect(_v4.size(clock.timers)).to.eql(1);
|
||||
var id = _v4.keys(clock.timers).pop();
|
||||
clock.tick(25000);
|
||||
expect(trans.sniff.callCount).to.eql(1);
|
||||
expect(_.size(clock.timers)).to.eql(1);
|
||||
expect(_v4.size(clock.timers)).to.eql(1);
|
||||
expect(clock.timers).to.not.have.key(id);
|
||||
|
||||
});
|
||||
@ -285,7 +285,7 @@ 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');
|
||||
var trans = new Transport({
|
||||
@ -295,7 +295,7 @@ describe('Transport Class', function () {
|
||||
expect(_v4.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');
|
||||
var trans = new Transport({
|
||||
@ -606,7 +606,7 @@ describe('Transport Class', function () {
|
||||
}
|
||||
|
||||
var trans = new Transport({
|
||||
hosts: _.map(new Array(retries + 1), function (val, i) {
|
||||
hosts: _v4.map(new Array(retries + 1), function (val, i) {
|
||||
return 'localhost/' + i;
|
||||
}),
|
||||
maxRetries: retries,
|
||||
@ -617,7 +617,7 @@ describe('Transport Class', function () {
|
||||
});
|
||||
|
||||
// trigger a select so that we can harvest the connection list
|
||||
trans.connectionPool.select(_.noop);
|
||||
trans.connectionPool.select(_v4.noop);
|
||||
_v4.each(connections, function (conn) {
|
||||
stub(conn, 'request', failRequest);
|
||||
});
|
||||
@ -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({}, _.noop);
|
||||
var ret = tran.request({}, _v4.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(_.noop, _.noop); // prevent complaining from bluebird
|
||||
ret.then(_v4.noop, _v4.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: _.noop,
|
||||
reject: _.noop,
|
||||
resolve: _v4.noop,
|
||||
reject: _v4.noop,
|
||||
promise: fakePromise
|
||||
};
|
||||
}
|
||||
@ -759,9 +759,9 @@ describe('Transport Class', function () {
|
||||
|
||||
var prom = tran.request({});
|
||||
// disregard promise, prevent bluebird's warnings
|
||||
prom.then(_.noop, _.noop);
|
||||
prom.then(_v4.noop, _v4.noop);
|
||||
|
||||
expect(_.size(clock.timers)).to.eql(1);
|
||||
expect(_v4.size(clock.timers)).to.eql(1);
|
||||
_v4.each(clock.timers, function (timer, id) {
|
||||
expect(timer.callAt).to.eql(30000);
|
||||
clearTimeout(id);
|
||||
@ -776,9 +776,9 @@ describe('Transport Class', function () {
|
||||
|
||||
var prom = tran.request({});
|
||||
// disregard promise, prevent bluebird's warnings
|
||||
prom.then(_.noop, _.noop);
|
||||
prom.then(_v4.noop, _v4.noop);
|
||||
|
||||
expect(_.size(clock.timers)).to.eql(1);
|
||||
expect(_v4.size(clock.timers)).to.eql(1);
|
||||
_v4.each(clock.timers, function (timer, id) {
|
||||
expect(timer.callAt).to.eql(5000);
|
||||
clearTimeout(id);
|
||||
@ -797,7 +797,7 @@ describe('Transport Class', function () {
|
||||
requestTimeout: falsy
|
||||
}, function () {});
|
||||
|
||||
expect(_.size(clock.timers)).to.eql(0);
|
||||
expect(_v4.size(clock.timers)).to.eql(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -7,7 +7,7 @@ var expect = require('expect.js');
|
||||
var sinon = require('sinon');
|
||||
var nock = require('../../mocks/server.js');
|
||||
var through2 = require('through2');
|
||||
var _ = require('lodash-migrate');
|
||||
// var _ = require('lodash');
|
||||
var nodeList = require('../../fixtures/short_node_list.json');
|
||||
var stub = require('../../utils/auto_release_stub').make();
|
||||
|
||||
@ -277,7 +277,7 @@ describe('Transport + Mock server', function () {
|
||||
expect(err).to.be(undefined);
|
||||
expect(resp).to.eql({ i: 'am here' });
|
||||
expect(status).to.eql(200);
|
||||
expect(_.keys(clock.timers)).to.have.length(0);
|
||||
expect(_v4.keys(clock.timers)).to.have.length(0);
|
||||
clock.restore();
|
||||
});
|
||||
});
|
||||
@ -342,9 +342,9 @@ describe('Transport + Mock server', function () {
|
||||
.catch(function (err) {
|
||||
expect(ConnectionPool.prototype._onConnectionDied.callCount).to.eql(1);
|
||||
expect(tran.sniff.callCount).to.eql(0);
|
||||
expect(_.size(clock.timers)).to.eql(1);
|
||||
expect(_v4.size(clock.timers)).to.eql(1);
|
||||
|
||||
var timeout = _.values(clock.timers).pop();
|
||||
var timeout = _v4.values(clock.timers).pop();
|
||||
timeout.func();
|
||||
expect(tran.sniff.callCount).to.eql(1);
|
||||
});
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var _ = require('../../../src/lib/utils');
|
||||
// var _ = require('../../../src/lib/utils');
|
||||
var expect = require('expect.js');
|
||||
|
||||
var stub = require('../../utils/auto_release_stub').make();
|
||||
@ -6,7 +6,7 @@ var stub = require('../../utils/auto_release_stub').make();
|
||||
describe('Utils', function () {
|
||||
|
||||
describe('Additional Type Checkers', function () {
|
||||
_.forEach({
|
||||
_v4.forEach({
|
||||
Object: {
|
||||
is: [[], /regexp/]
|
||||
},
|
||||
@ -34,66 +34,66 @@ describe('Utils', function () {
|
||||
function (thing, name) {
|
||||
describe('#isArrayOf' + name, function () {
|
||||
it('likes arrays of ' + name, function () {
|
||||
expect(_['isArrayOf' + name + 's'](thing.is)).to.be(true);
|
||||
expect(_v4['isArrayOf' + name + 's'](thing.is)).to.be(true);
|
||||
});
|
||||
|
||||
it('dislikes when there is even one non ' + name, function () {
|
||||
// notice a string in the array
|
||||
thing.is.push(thing.not || ' not ');
|
||||
expect(_['isArrayOf' + name + 's'](thing.is)).to.be(false);
|
||||
expect(_v4['isArrayOf' + name + 's'](thing.is)).to.be(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isNumeric', function () {
|
||||
it('likes integer literals', function () {
|
||||
expect(_.isNumeric('-10')).to.be(true);
|
||||
expect(_.isNumeric('0')).to.be(true);
|
||||
expect(_.isNumeric('5')).to.be(true);
|
||||
expect(_.isNumeric(-16)).to.be(true);
|
||||
expect(_.isNumeric(0)).to.be(true);
|
||||
expect(_.isNumeric(32)).to.be(true);
|
||||
expect(_.isNumeric('040')).to.be(true);
|
||||
expect(_.isNumeric('0xFF')).to.be(true);
|
||||
expect(_.isNumeric(0xFFF)).to.be(true);
|
||||
expect(_v4.isNumeric('-10')).to.be(true);
|
||||
expect(_v4.isNumeric('0')).to.be(true);
|
||||
expect(_v4.isNumeric('5')).to.be(true);
|
||||
expect(_v4.isNumeric(-16)).to.be(true);
|
||||
expect(_v4.isNumeric(0)).to.be(true);
|
||||
expect(_v4.isNumeric(32)).to.be(true);
|
||||
expect(_v4.isNumeric('040')).to.be(true);
|
||||
expect(_v4.isNumeric('0xFF')).to.be(true);
|
||||
expect(_v4.isNumeric(0xFFF)).to.be(true);
|
||||
});
|
||||
|
||||
it('likes float literals', function () {
|
||||
expect(_.isNumeric('-1.6')).to.be(true);
|
||||
expect(_.isNumeric('4.536')).to.be(true);
|
||||
expect(_.isNumeric(-2.6)).to.be(true);
|
||||
expect(_.isNumeric(3.1415)).to.be(true);
|
||||
expect(_.isNumeric(8e5)).to.be(true);
|
||||
expect(_.isNumeric('123e-2')).to.be(true);
|
||||
expect(_v4.isNumeric('-1.6')).to.be(true);
|
||||
expect(_v4.isNumeric('4.536')).to.be(true);
|
||||
expect(_v4.isNumeric(-2.6)).to.be(true);
|
||||
expect(_v4.isNumeric(3.1415)).to.be(true);
|
||||
expect(_v4.isNumeric(8e5)).to.be(true);
|
||||
expect(_v4.isNumeric('123e-2')).to.be(true);
|
||||
});
|
||||
|
||||
it('dislikes non-numeric stuff', function () {
|
||||
expect(_.isNumeric('')).to.be(false);
|
||||
expect(_.isNumeric(' ')).to.be(false);
|
||||
expect(_.isNumeric('\t\t')).to.be(false);
|
||||
expect(_.isNumeric('abcdefghijklm1234567890')).to.be(false);
|
||||
expect(_.isNumeric('xabcdefx')).to.be(false);
|
||||
expect(_.isNumeric(true)).to.be(false);
|
||||
expect(_.isNumeric(false)).to.be(false);
|
||||
expect(_.isNumeric('bcfed5.2')).to.be(false);
|
||||
expect(_.isNumeric('7.2acdgs')).to.be(false);
|
||||
expect(_.isNumeric(undefined)).to.be(false);
|
||||
expect(_.isNumeric(null)).to.be(false);
|
||||
expect(_.isNumeric(NaN)).to.be(false);
|
||||
expect(_.isNumeric(Infinity)).to.be(false);
|
||||
expect(_.isNumeric(Number.POSITIVE_INFINITY)).to.be(false);
|
||||
expect(_.isNumeric(Number.NEGATIVE_INFINITY)).to.be(false);
|
||||
expect(_.isNumeric(new Date(2009, 1, 1))).to.be(false);
|
||||
expect(_.isNumeric([])).to.be(false);
|
||||
expect(_.isNumeric([1, 2, 3, 4])).to.be(false);
|
||||
expect(_.isNumeric({})).to.be(false);
|
||||
expect(_.isNumeric(function () {})).to.be(false);
|
||||
expect(_v4.isNumeric('')).to.be(false);
|
||||
expect(_v4.isNumeric(' ')).to.be(false);
|
||||
expect(_v4.isNumeric('\t\t')).to.be(false);
|
||||
expect(_v4.isNumeric('abcdefghijklm1234567890')).to.be(false);
|
||||
expect(_v4.isNumeric('xabcdefx')).to.be(false);
|
||||
expect(_v4.isNumeric(true)).to.be(false);
|
||||
expect(_v4.isNumeric(false)).to.be(false);
|
||||
expect(_v4.isNumeric('bcfed5.2')).to.be(false);
|
||||
expect(_v4.isNumeric('7.2acdgs')).to.be(false);
|
||||
expect(_v4.isNumeric(undefined)).to.be(false);
|
||||
expect(_v4.isNumeric(null)).to.be(false);
|
||||
expect(_v4.isNumeric(NaN)).to.be(false);
|
||||
expect(_v4.isNumeric(Infinity)).to.be(false);
|
||||
expect(_v4.isNumeric(Number.POSITIVE_INFINITY)).to.be(false);
|
||||
expect(_v4.isNumeric(Number.NEGATIVE_INFINITY)).to.be(false);
|
||||
expect(_v4.isNumeric(new Date(2009, 1, 1))).to.be(false);
|
||||
expect(_v4.isNumeric([])).to.be(false);
|
||||
expect(_v4.isNumeric([1, 2, 3, 4])).to.be(false);
|
||||
expect(_v4.isNumeric({})).to.be(false);
|
||||
expect(_v4.isNumeric(function () {})).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('#isInterval', function () {
|
||||
_.forEach({
|
||||
_v4.forEach({
|
||||
M: 'months',
|
||||
w: 'weeks',
|
||||
d: 'days',
|
||||
@ -104,20 +104,20 @@ describe('Utils', function () {
|
||||
},
|
||||
function (name, unit) {
|
||||
it('likes ' + name, function () {
|
||||
expect(_.isInterval('1' + unit)).to.be(true);
|
||||
expect(_v4.isInterval('1' + unit)).to.be(true);
|
||||
});
|
||||
|
||||
it('likes decimal ' + name, function () {
|
||||
expect(_.isInterval('1.5' + unit)).to.be(true);
|
||||
expect(_v4.isInterval('1.5' + unit)).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('dislikes more than one unit', function () {
|
||||
expect(_.isInterval('1my')).to.be(false);
|
||||
expect(_v4.isInterval('1my')).to.be(false);
|
||||
});
|
||||
|
||||
it('dislikes spaces', function () {
|
||||
expect(_.isInterval('1 m')).to.be(false);
|
||||
expect(_v4.isInterval('1 m')).to.be(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -127,108 +127,108 @@ describe('Utils', function () {
|
||||
|
||||
describe('#camelCase', function () {
|
||||
it('find spaces, underscores, and other natural word breaks', function () {
|
||||
expect(_.camelCase('Neil Patrick.Harris-is_a.dog')).to.eql('neilPatrickHarrisIsADog');
|
||||
expect(_v4.camelCase('Neil Patrick.Harris-is_a.dog')).to.eql('neilPatrickHarrisIsADog');
|
||||
});
|
||||
|
||||
it('ignores abreviations', function () {
|
||||
expect(_.camelCase('Json_parser')).to.eql('jsonParser');
|
||||
expect(_v4.camelCase('Json_parser')).to.eql('jsonParser');
|
||||
});
|
||||
|
||||
it('handles leading _', function () {
|
||||
expect(_.camelCase('_thing_one_')).to.eql('_thingOne');
|
||||
expect(_v4.camelCase('_thing_one_')).to.eql('_thingOne');
|
||||
});
|
||||
|
||||
it('works on numbers', function () {
|
||||
expect(_.camelCase('version 1.0')).to.eql('version10');
|
||||
expect(_v4.camelCase('version 1.0')).to.eql('version10');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#studlyCase', function () {
|
||||
it('find spaces, underscores, and other natural word breaks', function () {
|
||||
expect(_.studlyCase('Neil Patrick.Harris-is_a.dog')).to.eql('NeilPatrickHarrisIsADog');
|
||||
expect(_v4.studlyCase('Neil Patrick.Harris-is_a.dog')).to.eql('NeilPatrickHarrisIsADog');
|
||||
});
|
||||
|
||||
it('ignores abreviations', function () {
|
||||
expect(_.studlyCase('Json_parser')).to.eql('JsonParser');
|
||||
expect(_v4.studlyCase('Json_parser')).to.eql('JsonParser');
|
||||
});
|
||||
|
||||
it('handles leading _', function () {
|
||||
expect(_.studlyCase('_thing_one_')).to.eql('_ThingOne');
|
||||
expect(_v4.studlyCase('_thing_one_')).to.eql('_ThingOne');
|
||||
});
|
||||
|
||||
it('works on numbers', function () {
|
||||
expect(_.studlyCase('version 1.0')).to.eql('Version10');
|
||||
expect(_v4.studlyCase('version 1.0')).to.eql('Version10');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#snakeCase', function () {
|
||||
it('find spaces, underscores, and other natural word breaks', function () {
|
||||
expect(_.snakeCase('Neil Patrick.Harris-is_a.dog')).to.eql('neil_patrick_harris_is_a_dog');
|
||||
expect(_v4.snakeCase('Neil Patrick.Harris-is_a.dog')).to.eql('neil_patrick_harris_is_a_dog');
|
||||
});
|
||||
|
||||
it('ignores abreviations', function () {
|
||||
expect(_.snakeCase('Json_parser')).to.eql('json_parser');
|
||||
expect(_v4.snakeCase('Json_parser')).to.eql('json_parser');
|
||||
});
|
||||
|
||||
it('handles leading _', function () {
|
||||
expect(_.snakeCase('_thing_one_')).to.eql('_thing_one');
|
||||
expect(_v4.snakeCase('_thing_one_')).to.eql('_thing_one');
|
||||
});
|
||||
|
||||
it('works on numbers', function () {
|
||||
expect(_.snakeCase('version 1.0')).to.eql('version_1_0');
|
||||
expect(_v4.snakeCase('version 1.0')).to.eql('version_1_0');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#toLowerString', function () {
|
||||
it('transforms normal strings', function () {
|
||||
expect(_.toLowerString('PASTA')).to.eql('pasta');
|
||||
expect(_v4.toLowerString('PASTA')).to.eql('pasta');
|
||||
});
|
||||
|
||||
it('ignores long form empty vals (null, false, undef)', function () {
|
||||
expect(_.toLowerString(null)).to.eql('');
|
||||
expect(_.toLowerString(false)).to.eql('');
|
||||
expect(_.toLowerString(void 0)).to.eql('');
|
||||
expect(_v4.toLowerString(null)).to.eql('');
|
||||
expect(_v4.toLowerString(false)).to.eql('');
|
||||
expect(_v4.toLowerString(void 0)).to.eql('');
|
||||
});
|
||||
|
||||
it('uses the objects own toString', function () {
|
||||
expect(_.toLowerString(['A', 'B'])).to.eql('a,b');
|
||||
expect(_v4.toLowerString(['A', 'B'])).to.eql('a,b');
|
||||
});
|
||||
|
||||
it('sorta kinda works on objects', function () {
|
||||
expect(_.toLowerString({ a: 'thing' })).to.eql('[object object]');
|
||||
expect(_v4.toLowerString({ a: 'thing' })).to.eql('[object object]');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#toUpperString', function () {
|
||||
it('transforms normal strings', function () {
|
||||
expect(_.toUpperString('PASTA')).to.eql('PASTA');
|
||||
expect(_v4.toUpperString('PASTA')).to.eql('PASTA');
|
||||
});
|
||||
|
||||
it('ignores long form empty vals (null, false, undef)', function () {
|
||||
expect(_.toUpperString(null)).to.eql('');
|
||||
expect(_.toUpperString(false)).to.eql('');
|
||||
expect(_.toUpperString(void 0)).to.eql('');
|
||||
expect(_v4.toUpperString(null)).to.eql('');
|
||||
expect(_v4.toUpperString(false)).to.eql('');
|
||||
expect(_v4.toUpperString(void 0)).to.eql('');
|
||||
});
|
||||
|
||||
it('uses the objects own toString', function () {
|
||||
expect(_.toUpperString(['A', 'B'])).to.eql('A,B');
|
||||
expect(_v4.toUpperString(['A', 'B'])).to.eql('A,B');
|
||||
});
|
||||
|
||||
it('sorta kinda works on objects', function () {
|
||||
expect(_.toUpperString({ a: 'thing' })).to.eql('[OBJECT OBJECT]');
|
||||
expect(_v4.toUpperString({ a: 'thing' })).to.eql('[OBJECT OBJECT]');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#repeat', function () {
|
||||
it('repeats strings', function () {
|
||||
expect(_.repeat(' ', 5)).to.eql(' ');
|
||||
expect(_.repeat('foobar', 2)).to.eql('foobarfoobar');
|
||||
expect(_v4.repeat(' ', 5)).to.eql(' ');
|
||||
expect(_v4.repeat('foobar', 2)).to.eql('foobarfoobar');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#ucfirst', function () {
|
||||
it('only capitalized the first letter, lowercases everything else', function () {
|
||||
expect(_.ucfirst('ALGER')).to.eql('Alger');
|
||||
expect(_v4.ucfirst('ALGER')).to.eql('Alger');
|
||||
});
|
||||
});
|
||||
|
||||
@ -241,14 +241,14 @@ describe('Utils', function () {
|
||||
var obj = {
|
||||
foo: 'bar'
|
||||
};
|
||||
expect(_.deepMerge(obj, { bar: 'baz' })).to.eql(obj);
|
||||
expect(_v4.deepMerge(obj, { bar: 'baz' })).to.eql(obj);
|
||||
});
|
||||
|
||||
it('concats arrays', function () {
|
||||
var obj = {
|
||||
foo: ['bax', 'boz']
|
||||
};
|
||||
_.deepMerge(obj, { foo: ['boop'] });
|
||||
_v4.deepMerge(obj, { foo: ['boop'] });
|
||||
expect(obj.foo).to.have.length(3);
|
||||
});
|
||||
|
||||
@ -256,7 +256,7 @@ describe('Utils', function () {
|
||||
var obj = {
|
||||
foo: ['stop', 'foo', 'stahp']
|
||||
};
|
||||
_.deepMerge(obj, { foo: 'string' });
|
||||
_v4.deepMerge(obj, { foo: 'string' });
|
||||
expect(obj.foo).to.have.length(3);
|
||||
});
|
||||
|
||||
@ -267,7 +267,7 @@ describe('Utils', function () {
|
||||
foo: ['bax', 'boz']
|
||||
}
|
||||
};
|
||||
_.deepMerge(obj, { bax: { foo: ['poo'] } });
|
||||
_v4.deepMerge(obj, { bax: { foo: ['poo'] } });
|
||||
expect(obj.bax.foo).to.have.length(3);
|
||||
});
|
||||
|
||||
@ -276,26 +276,26 @@ describe('Utils', function () {
|
||||
describe('#createArray', function () {
|
||||
it('accepts an array of things and simply returns a copy of it', function () {
|
||||
var inp = [{ a: 1 }, 'pizza'];
|
||||
var out = _.createArray(inp);
|
||||
var out = _v4.createArray(inp);
|
||||
expect(out).to.eql(inp);
|
||||
expect(out).to.not.be(inp);
|
||||
});
|
||||
it('accepts a primitive value and calls the the transform function', function (done) {
|
||||
_.createArray('str', function (val) {
|
||||
_v4.createArray('str', function (val) {
|
||||
expect(val).to.be('str');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('wraps any non-array in an array', function () {
|
||||
expect(_.createArray({})).to.eql([{}]);
|
||||
expect(_.createArray('')).to.eql(['']);
|
||||
expect(_.createArray(123)).to.eql([123]);
|
||||
expect(_.createArray(/abc/)).to.eql([/abc/]);
|
||||
expect(_.createArray(false)).to.eql([false]);
|
||||
expect(_v4.createArray({})).to.eql([{}]);
|
||||
expect(_v4.createArray('')).to.eql(['']);
|
||||
expect(_v4.createArray(123)).to.eql([123]);
|
||||
expect(_v4.createArray(/abc/)).to.eql([/abc/]);
|
||||
expect(_v4.createArray(false)).to.eql([false]);
|
||||
});
|
||||
it('returns false when the transform function returns undefined', function () {
|
||||
expect(_.createArray(['str', 1], function (val) {
|
||||
if (_.isString(val)) {
|
||||
expect(_v4.createArray(['str', 1], function (val) {
|
||||
if (_v4.isString(val)) {
|
||||
return {
|
||||
val: val
|
||||
};
|
||||
@ -306,27 +306,27 @@ describe('Utils', function () {
|
||||
|
||||
describe('#funcEnum', function () {
|
||||
/*
|
||||
* _.funcEnum(object, key, opts, default);
|
||||
* _v4.funcEnum(object, key, opts, default);
|
||||
*/
|
||||
it('tests if the value at key in object is a function, returns it if so', function () {
|
||||
var config = {
|
||||
func: function () {}
|
||||
};
|
||||
expect(_.funcEnum(config, 'func', {}, 'toString'))
|
||||
expect(_v4.funcEnum(config, 'func', {}, 'toString'))
|
||||
.to.be(config.func);
|
||||
});
|
||||
it('tests if the value at key in object is undefined, returns the option at key default if so', function () {
|
||||
var config = {
|
||||
func: undefined
|
||||
};
|
||||
expect(_.funcEnum(config, 'func', {}, 'toString'))
|
||||
expect(_v4.funcEnum(config, 'func', {}, 'toString'))
|
||||
.to.be(Object.prototype.toString);
|
||||
});
|
||||
it('tests if the value at key in object is a string, returns the option at that key if so', function () {
|
||||
var config = {
|
||||
'config key name': 'toString'
|
||||
};
|
||||
expect(_.funcEnum(config, 'config key name', { toString: 'pizza' }, 'toJSON'))
|
||||
expect(_v4.funcEnum(config, 'config key name', { toString: 'pizza' }, 'toJSON'))
|
||||
.to.be('pizza');
|
||||
});
|
||||
it('throws an informative error if the selection if invalid', function () {
|
||||
@ -335,15 +335,15 @@ describe('Utils', function () {
|
||||
};
|
||||
|
||||
expect(function () {
|
||||
_.funcEnum(config, 'config', {});
|
||||
_v4.funcEnum(config, 'config', {});
|
||||
}).to.throwError(/expected a function/i);
|
||||
|
||||
expect(function () {
|
||||
_.funcEnum(config, 'config', { main: 'default' }, 'main');
|
||||
_v4.funcEnum(config, 'config', { main: 'default' }, 'main');
|
||||
}).to.throwError(/expected a function or main/i);
|
||||
|
||||
expect(function () {
|
||||
_.funcEnum(config, 'config', { main: 'default', other: 'default' }, 'main');
|
||||
_v4.funcEnum(config, 'config', { main: 'default', other: 'default' }, 'main');
|
||||
}).to.throwError(/expected a function or one of main, other/i);
|
||||
});
|
||||
});
|
||||
@ -358,8 +358,8 @@ describe('Utils', function () {
|
||||
var func = function () {};
|
||||
stub(func, method);
|
||||
|
||||
var args = _.map(new Array(i), function (val, i) { return i; });
|
||||
_.applyArgs(func, null, args);
|
||||
var args = _v4.map(new Array(i), function (val, i) { return i; });
|
||||
_v4.applyArgs(func, null, args);
|
||||
|
||||
expect(func[method].callCount).to.eql(1);
|
||||
if (method === 'apply') {
|
||||
@ -374,9 +374,9 @@ describe('Utils', function () {
|
||||
var func = function () {};
|
||||
stub(func, method);
|
||||
|
||||
var args = _.map(new Array(argCount), function (val, i) { return i; });
|
||||
var args = _v4.map(new Array(argCount), function (val, i) { return i; });
|
||||
var expected = args.slice(slice);
|
||||
_.applyArgs(func, null, args, slice);
|
||||
_v4.applyArgs(func, null, args, slice);
|
||||
|
||||
expect(func[method].callCount).to.eql(1);
|
||||
if (method === 'apply') {
|
||||
@ -390,24 +390,24 @@ describe('Utils', function () {
|
||||
|
||||
describe('#getUnwrittenFromStream', function () {
|
||||
it('ignores things that do not have writableState', function () {
|
||||
expect(_.getUnwrittenFromStream()).to.be(undefined);
|
||||
expect(_.getUnwrittenFromStream(false)).to.be(undefined);
|
||||
expect(_.getUnwrittenFromStream([])).to.be(undefined);
|
||||
expect(_.getUnwrittenFromStream({})).to.be(undefined);
|
||||
expect(_v4.getUnwrittenFromStream()).to.be(undefined);
|
||||
expect(_v4.getUnwrittenFromStream(false)).to.be(undefined);
|
||||
expect(_v4.getUnwrittenFromStream([])).to.be(undefined);
|
||||
expect(_v4.getUnwrittenFromStream({})).to.be(undefined);
|
||||
});
|
||||
|
||||
if (require('stream').Writable) {
|
||||
var MockWritableStream = require('../../mocks/writable_stream');
|
||||
it('ignores empty stream', function () {
|
||||
var stream = new MockWritableStream();
|
||||
expect(_.getUnwrittenFromStream(stream)).to.be('');
|
||||
expect(_v4.getUnwrittenFromStream(stream)).to.be('');
|
||||
});
|
||||
|
||||
it('returns only what is in the buffer', function () {
|
||||
var stream = new MockWritableStream();
|
||||
stream.write('hot');
|
||||
stream.write('dog');
|
||||
expect(_.getUnwrittenFromStream(stream)).to.be('dog');
|
||||
expect(_v4.getUnwrittenFromStream(stream)).to.be('dog');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user