mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Add _.spread tests for the start param.
This commit is contained in:
36
test/test.js
36
test/test.js
@@ -18577,11 +18577,15 @@
|
||||
QUnit.module('lodash.spread');
|
||||
|
||||
(function() {
|
||||
function fn(a, b, c) {
|
||||
return slice.call(arguments);
|
||||
}
|
||||
|
||||
QUnit.test('should spread arguments to `func`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var spread = _.spread(add);
|
||||
assert.strictEqual(spread([4, 2]), 6);
|
||||
var spread = _.spread(fn);
|
||||
assert.deepEqual(spread([4, 2]), [4, 2]);
|
||||
});
|
||||
|
||||
QUnit.test('should accept a falsey `array` argument', function(assert) {
|
||||
@@ -18611,6 +18615,34 @@
|
||||
spread([4, 2], 'ignored');
|
||||
assert.deepEqual(args, [4, 2]);
|
||||
});
|
||||
|
||||
QUnit.test('should work with `start`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var spread = _.spread(fn, 1);
|
||||
assert.deepEqual(spread(1, [2, 3, 4]), [1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
QUnit.test('should treat `start` as `0` for negative or `NaN` values', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var values = [-1, NaN, 'a'],
|
||||
expected = lodashStable.map(values, lodashStable.constant([1, 2, 3, 4]));
|
||||
|
||||
var actual = lodashStable.map(values, function(value) {
|
||||
var spread = _.spread(fn, value);
|
||||
return spread([1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
QUnit.test('should coerce `start` to an integer', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var spread = _.spread(fn, 1.6);
|
||||
assert.deepEqual(spread(1, [2, 3]), [1, 2, 3]);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user