Files
ConvertX/tests/converters/libjxl.test.ts
T
Emrik Östling 2135c6b9f1 chore: use bun fmt and bun check (#685)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-10-23 18:23:49 +02:00

42 lines
1.4 KiB
TypeScript

import { expect, test } from "bun:test";
import { convert } from "../../src/converters/libjxl";
import { runCommonTests } from "./helpers/commonTests";
import { createMockExecFile } from "./helpers/converters";
runCommonTests(convert);
test("convert uses djxl with input filetype being jxl", async () => {
const { execFile, calls } = createMockExecFile();
const result = await convert("input.jxl", "jxl", "png", "output.png", undefined, execFile);
expect(result).toBe("Done");
expect(calls).toEqual([{ cmd: "djxl", args: ["input.jxl", "output.png"] }]);
});
test("convert uses cjxl with output filetype being jxl", async () => {
const { execFile, calls } = createMockExecFile();
const result = await convert("input.png", "png", "jxl", "output.jxl", undefined, execFile);
expect(result).toBe("Done");
expect(calls).toEqual([{ cmd: "cjxl", args: ["input.png", "output.jxl"] }]);
});
test("convert prefers cjxl when both input and output filetype are jxl", async () => {
const { execFile, calls } = createMockExecFile();
await convert("input.jxl", "jxl", "jxl", "output.jxl", undefined, execFile);
expect(calls[0]?.cmd).toBe("cjxl");
});
test("convert uses empty string as command with neither input nor output filetype being jxl", async () => {
const { execFile, calls } = createMockExecFile();
await convert("input.png", "png", "jpg", "output.jpg", undefined, execFile);
expect(calls[0]?.cmd).toBe("");
});