mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 16:47:49 +00:00
Rename _.asArray to _.castArray and add _.castFunction and _.castPath.
This commit is contained in:
72
test/test.js
72
test/test.js
@@ -2158,6 +2158,35 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.castArray');
|
||||
|
||||
(function() {
|
||||
QUnit.test('should wrap non array items in an array', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var values = falsey.concat(true, 1, 'a', { 'a': 1 }),
|
||||
expected = lodashStable.map(values, function(value) { return [value]; }),
|
||||
actual = lodashStable.map(values, _.castArray);
|
||||
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
QUnit.test('should return array values by reference', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var array = [1];
|
||||
assert.strictEqual(_.castArray(array), array);
|
||||
});
|
||||
|
||||
QUnit.test('should return an empty array when no arguments are given', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
assert.deepEqual(_.castArray(), []);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.chain');
|
||||
|
||||
(function() {
|
||||
@@ -21185,47 +21214,6 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.asArray');
|
||||
|
||||
(function() {
|
||||
var wrapCases = [null, void 0, 1, '', 'ab', 0, {a: 1}, Object('xyz')];
|
||||
|
||||
QUnit.test('should wrap non array items in an array', function(assert) {
|
||||
assert.expect(wrapCases.length * 2);
|
||||
|
||||
_.each(wrapCases, function(val) {
|
||||
var result = _.asArray(val);
|
||||
assert.deepEqual(result, [val], 'for value ' + val);
|
||||
assert.strictEqual(result[0], val, 'should not copy the value');
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('should an array copy if provided array', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var arr = [1, 2, '3'];
|
||||
assert.deepEqual(_.asArray(arr), arr);
|
||||
assert.notStrictEqual(_.asArray(arr), arr);
|
||||
});
|
||||
|
||||
QUnit.test('should convert iterables to arrays', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
if (!isNpm && Symbol && Symbol.iterator) {
|
||||
var object = { '0': 'a', 'length': 1 };
|
||||
object[Symbol.iterator] = arrayProto[Symbol.iterator];
|
||||
|
||||
assert.deepEqual(_.asArray(object), ['a']);
|
||||
}
|
||||
else {
|
||||
skipAssert(assert);
|
||||
}
|
||||
});
|
||||
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.toLower');
|
||||
|
||||
(function() {
|
||||
@@ -24125,7 +24113,7 @@
|
||||
var acceptFalsey = lodashStable.difference(allMethods, rejectFalsey);
|
||||
|
||||
QUnit.test('should accept falsey arguments', function(assert) {
|
||||
assert.expect(297);
|
||||
assert.expect(299);
|
||||
|
||||
var emptyArrays = lodashStable.map(falsey, alwaysEmptyArray);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user