// src/lib/db/chunk.test.ts — pure unit tests (no DB).
import { describe, expect, test } from "bun:test";
import { chunk } from "./chunk";

describe("chunk", () => {
  test("splits into consecutive slices with remainder", () => {
    expect(chunk([1, 2, 3, 4, 5], 2)).toEqual([[1, 2], [3, 4], [5]]);
  });

  test("empty input yields no chunks", () => {
    expect(chunk([], 500)).toEqual([]);
  });

  test("size >= length yields a single chunk", () => {
    expect(chunk([1, 2], 10)).toEqual([[1, 2]]);
  });

  test("exact multiple yields full chunks only", () => {
    expect(chunk([1, 2, 3, 4], 2)).toEqual([
      [1, 2],
      [3, 4],
    ]);
  });
});
