mirror of
https://github.com/C4illin/ConvertX.git
synced 2026-10-28 07:44:21 +01:00
2135c6b9f1
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
42 lines
1.4 KiB
TypeScript
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("");
|
|
});
|