import { describe, expect } from "@jest/globals"

import { chunk } from "./chunk"

describe("chunk", () => {
  it("should split an array into equally sized chunks of specified size", () => {
    const array = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    const size = 3
    const expected = [
      [1, 2, 3],
      [4, 5, 6],
      [7, 8, 9],
    ]

    expect(chunk(array, size)).toEqual(expected)
  })

  it("should split an array into equally sized chunks of specified size", () => {
    const array = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    const size = 4
    const expected = [[1, 2, 3, 4], [5, 6, 7, 8], [9]]

    expect(chunk(array, size)).toEqual(expected)
  })
})
