mirror of
https://github.com/C4illin/ConvertX.git
synced 2026-10-27 23:30:55 +01:00
2135c6b9f1
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { expect, test } from "bun:test";
|
|
import type { ExecFileException } from "node:child_process";
|
|
|
|
import { convert, properties } from "../../src/converters/djvu";
|
|
import type { ExecFileFn } from "../../src/converters/types";
|
|
import { runCommonTests } from "./helpers/commonTests";
|
|
|
|
runCommonTests(convert);
|
|
|
|
test("advertises DjVu to PDF and TIFF conversions", () => {
|
|
expect(properties).toEqual({
|
|
from: { document: ["djvu", "djv"] },
|
|
to: { document: ["pdf", "tiff"] },
|
|
});
|
|
});
|
|
|
|
for (const format of ["pdf", "tiff"]) {
|
|
test(`calls ddjvu with the ${format} output format`, async () => {
|
|
let command = "";
|
|
let args: string[] = [];
|
|
const mockExecFile: ExecFileFn = (
|
|
cmd: string,
|
|
commandArgs: string[],
|
|
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
|
) => {
|
|
command = cmd;
|
|
args = commandArgs;
|
|
callback(null, "", "");
|
|
};
|
|
|
|
await expect(
|
|
convert("input.djvu", "djvu", format, `output.${format}`, undefined, mockExecFile),
|
|
).resolves.toBe("Done");
|
|
expect(command).toBe("ddjvu");
|
|
expect(args).toEqual([`-format=${format}`, "input.djvu", `output.${format}`]);
|
|
});
|
|
}
|