|
538 | 538 | deepEqual(_.range(12, 7, -2), [12, 10, 8], 'range with three arguments a & b & c, a > b, c < 0 generates an array of elements a,a-c,a-2c and ends with the number not less than b'); |
539 | 539 | deepEqual(_.range(0, -10, -1), [0, -1, -2, -3, -4, -5, -6, -7, -8, -9], 'final example in the Python docs'); |
540 | 540 | }); |
541 | | - |
| 541 | + |
| 542 | + test('chunk', function() { |
| 543 | + deepEqual(_.chunk([], 2), [], 'chunk for empty array returns an empty array'); |
| 544 | + deepEqual(_.chunk(null, 2), [], 'chunk for null returns an empty array'); |
| 545 | + |
| 546 | + deepEqual(_.chunk([1, 2, 3], 0), [], 'chunk into parts of 0 elements returns an empty array'); |
| 547 | + deepEqual(_.chunk([1, 2, 3], -1), [], 'chunk into parts of negative amount of elements returns an empty array'); |
| 548 | + |
| 549 | + deepEqual(_.chunk([1, 2, 3], 3), [[1, 2, 3]], 'chunk into parts of current array length elements returns the original array'); |
| 550 | + deepEqual(_.chunk([1, 2, 3], 5), [[1, 2, 3]], 'chunk into parts of more then current array length elements returns the original array'); |
| 551 | + |
| 552 | + deepEqual(_.chunk([10, 20, 30, 40, 50, 60, 70], 2), [[10, 20], [30, 40], [50, 60], [70]], 'chunk into parts of less then current array length elements'); |
| 553 | + deepEqual(_.chunk([10, 20, 30, 40, 50, 60, 70], 3), [[10, 20, 30], [40, 50, 60], [70]], 'chunk into parts of less then current array length elements'); |
| 554 | + }); |
| 555 | + |
542 | 556 | }()); |
0 commit comments