ts-prime
Version:
A utility library for JavaScript and Typescript.
30 lines (29 loc) • 786 B
JavaScript
import { chunk } from './chunk';
describe('data first', function () {
test('equal size', function () {
expect(chunk(['a', 'b', 'c', 'd'], 2)).toEqual([
['a', 'b'],
['c', 'd'],
]);
});
test('not equal size', function () {
expect(chunk(['a', 'b', 'c', 'd'], 3)).toEqual([
['a', 'b', 'c'],
['d'],
]);
});
test('1 element', function () {
expect(chunk(['x'], 3)).toEqual([['x']]);
});
test('empty array', function () {
expect(chunk([], 3)).toEqual([]);
});
});
describe('data last', function () {
test('equal size', function () {
expect(chunk(2)(['a', 'b', 'c', 'd'])).toEqual([
['a', 'b'],
['c', 'd'],
]);
});
});