import { describe, expect, it } from "vitest"; import { ImageError, MAX_IMAGE_BYTES, prepareImage } from "#lib/images.ts"; const file = (type: string, bytes: number, name = "seal") => new File([new Uint8Array(bytes)], name, { type }); describe("prepareImage", () => { it("keeps a supported image under the limit untouched", async () => { const png = file("image/png", 10); expect(await prepareImage(png)).toBe(png); }); it("refuses a gif over the limit rather than flattening it", async () => { await expect(prepareImage(file("image/gif", MAX_IMAGE_BYTES + 1))).rejects.toThrow( ImageError ); }); });