diff --git a/fixtures/image.avif b/fixtures/image.avif new file mode 100644 index 0000000..fad2b70 Binary files /dev/null and b/fixtures/image.avif differ diff --git a/packages/server/src/images/process-image-handler.spec.ts b/packages/server/src/images/process-image-handler.spec.ts index 027ee58..174778f 100644 --- a/packages/server/src/images/process-image-handler.spec.ts +++ b/packages/server/src/images/process-image-handler.spec.ts @@ -9,6 +9,7 @@ import { describe, expect, it } from "bun:test"; import { processImageHandler } from "./process-image-handler"; const fixture = Bun.file("../../fixtures/image.jpeg"); +const avifFixture = Bun.file("../../fixtures/image.avif"); describe("/process", () => { it("should process a single image", async () => { @@ -147,6 +148,29 @@ describe("/process", () => { ]); }); + it("should convert avif to avif", async () => { + const opts: RemoteImageOptions = { + format: "avif", + }; + const response = await processImageHandler( + new Request(`http://localhost:3000/images/process`, { + method: "POST", + body: avifFixture, + headers: { "X-Options": JSON.stringify(opts) }, + }) + ); + + expect(response.status).toBe(200); + const collected = await collectResponse(response); + + expect(collected).toEqual([ + { position: 0 }, + { progress: 0 }, + expect.objectContaining({ filename: "file1.avif", type: "image/avif" }), + { progress: 100 }, + ]); + }); + it("should not stream back, if output is provided", async () => { const opts: RemoteImageOptions = { format: "avif",