|
15 | 15 | result = _.map([[1, 2, 3], [1, 2, 3]], _.first); |
16 | 16 | assert.deepEqual(result, [1, 1], 'works well with _.map'); |
17 | 17 | assert.strictEqual(_.first(null), void 0, 'returns undefined when called on null'); |
| 18 | + assert.deepEqual(_.first([], 10), [], 'returns an empty array when called with an explicit number of elements to return'); |
| 19 | + assert.deepEqual(_.first([], 1), [], 'returns an empty array when called with an explicit number of elements to return'); |
| 20 | + assert.deepEqual(_.first(null, 5), [], 'returns an empty array when called with an explicit number of elements to return'); |
18 | 21 |
|
19 | 22 | Array.prototype[0] = 'boo'; |
20 | 23 | assert.strictEqual(_.first([]), void 0, 'return undefined when called on a empty array'); |
|
71 | 74 | assert.deepEqual(result, [3, 3], 'works well with _.map'); |
72 | 75 | assert.strictEqual(_.last(null), void 0, 'returns undefined when called on null'); |
73 | 76 |
|
| 77 | + assert.deepEqual(_.last([], 10), [], 'returns an empty array when called with an explicit number of elements to return'); |
| 78 | + assert.deepEqual(_.last([], 1), [], 'returns an empty array when called with an explicit number of elements to return'); |
| 79 | + assert.deepEqual(_.last(null, 5), [], 'returns an empty array when called with an explicit number of elements to return'); |
| 80 | + |
74 | 81 | var arr = []; |
75 | 82 | arr[-1] = 'boo'; |
76 | 83 | assert.strictEqual(_.last(arr), void 0, 'return undefined when called on a empty array'); |
|
0 commit comments