import { chunk } from './chunk';
import { range } from './range';

describe('chunk', () => {
  it('should split an array with 10 elements into two chunks with 5 elements', () => {
    const given = range(10);
    const when = chunk(given, 5);
    expect(when).toHaveLength(2);
    when.map((sub) => expect(sub).toHaveLength(5));
  });

  it('should split an array with 8 elements into two chunks, first with 5 elements, second with 3', () => {
    const given = range(8);
    const when = chunk(given, 5);
    expect(when).toHaveLength(2);
    expect(when[0]).toHaveLength(5);
    expect(when[1]).toHaveLength(3);
  });
});
