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
This commit is contained in:
Joakim Jäderberg
2025-05-26 09:39:48 +00:00
parent c963891ca7
commit b20c8ce42b
3 changed files with 98 additions and 74 deletions

View File

@@ -0,0 +1,25 @@
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)
})
})