test: add test case to libjxl.test.ts when input and output are not jxl
This commit is contained in:
parent
178f009458
commit
c6006b58d2
1 changed files with 26 additions and 0 deletions
|
|
@ -82,3 +82,29 @@ test("convert uses cjxl with output filetype being jxl", async () => {
|
||||||
expect(command).toEqual("cjxl");
|
expect(command).toEqual("cjxl");
|
||||||
expect(loggedMessage).toBe("stdout: Fake stdout");
|
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("convert uses empty string as command with neither input nor output filetype being jxl", async () => {
|
||||||
|
const originalConsoleLog = console.log;
|
||||||
|
|
||||||
|
let loggedMessage = "";
|
||||||
|
console.log = (msg) => {
|
||||||
|
loggedMessage = msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockExecFile: ExecFileFn = (
|
||||||
|
_cmd: string,
|
||||||
|
_args: string[],
|
||||||
|
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||||
|
) => {
|
||||||
|
command = _cmd;
|
||||||
|
callback(null, "Fake stdout", "");
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await convert("input.png", "png", "jpg", "output.jpg", undefined, mockExecFile);
|
||||||
|
|
||||||
|
console.log = originalConsoleLog;
|
||||||
|
|
||||||
|
expect(result).toBe("Done");
|
||||||
|
expect(command).toEqual("");
|
||||||
|
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue