Files
web/apps/scandic-web/utils/chunk.test.ts
Joakim Jäderberg b20c8ce42b Merged in fix/warmup-autocomplete-data-2 (pull request #2218)
fix: chunked data overwrote it self

* fix: chunked data overwrote it self


Approved-by: Linus Flood
2025-05-26 09:39:48 +00:00

26 lines
652 B
TypeScript

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)
})
})