import { appendCapped } from "./cap" describe("appendCapped", () => { test("keeps all items when under max", () => { expect(appendCapped([1, 2], [3], 10)).toEqual([1, 2, 3]) }) test("drops from head when exceeding max", () => { expect(appendCapped([1, 2], [3, 4, 5], 3)).toEqual([3, 4, 5]) }) test("calls onDrop for dropped items", () => { const dropped: number[] = [] const result = appendCapped([1, 2], [3, 4, 5], 3, (x) => dropped.push(x)) expect(result).toEqual([3, 4, 5]) expect(dropped).toEqual([1, 2]) }) })