Files
ConvertX/tests/converters/djvu.test.ts
T
al-n aabd0ccb3d feat: add DjVu conversion support (#612)
* feat: add DjVu conversion support

* fix: support DjVu aliases and prioritize converter

* fix: restore DjVu converter priority

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Alex N <alex@alex-n.net>
Co-authored-by: Emrik Östling <emrik.ostling@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-10-14 21:53:06 +02:00

37 lines
1.2 KiB
TypeScript

import type { ExecFileException } from "node:child_process";
import { expect, test } from "bun:test";
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}`]);
});
}