Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added fixtures/image.avif
Binary file not shown.
24 changes: 24 additions & 0 deletions packages/server/src/images/process-image-handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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",
Expand Down
Loading