refactor: use test.each for binary format tests
Address third round of cubic-dev-ai review feedback: P3: The three binary format tests (docx, epub, odt) were nearly identical in structure, differing only in the file extension. Consolidated into a single test.each parameterized test. Also fixed inconsistent test name (odt was missing the 'with -V adjacency' suffix). All three now use the unified name pattern via %s substitution.
This commit is contained in:
parent
13c8eea68a
commit
f161f68240
1 changed files with 13 additions and 32 deletions
|
|
@ -169,38 +169,19 @@ describe("convert", () => {
|
||||||
expect(calledArgs[1].some((arg) => arg.startsWith("CJKmainfont"))).toBe(false);
|
expect(calledArgs[1].some((arg) => arg.startsWith("CJKmainfont"))).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should always add CJK font for docx binary format with -V adjacency", async () => {
|
test.each(["docx", "epub", "odt"])(
|
||||||
let calledArgs: Parameters<ExecFileFn> = ["", [], () => {}];
|
"should always add CJK font for %s binary format with -V adjacency",
|
||||||
mockExecFile = (cmd, args, callback) => {
|
async (format: string) => {
|
||||||
calledArgs = [cmd, args, callback];
|
let calledArgs: Parameters<ExecFileFn> = ["", [], () => {}];
|
||||||
callback(null, "output-data", "");
|
mockExecFile = (cmd, args, callback) => {
|
||||||
};
|
calledArgs = [cmd, args, callback];
|
||||||
const filePath = makeTempFile("binary placeholder content", "docx");
|
callback(null, "output-data", "");
|
||||||
await convert(filePath, "docx", "pdf", "output.pdf", undefined, mockExecFile);
|
};
|
||||||
assertCJKFontArg(calledArgs[1], "Noto Sans CJK SC");
|
const filePath = makeTempFile("binary placeholder content", format);
|
||||||
});
|
await convert(filePath, format, "pdf", "output.pdf", undefined, mockExecFile);
|
||||||
|
assertCJKFontArg(calledArgs[1], "Noto Sans CJK SC");
|
||||||
test("should always add CJK font for epub binary format with -V adjacency", async () => {
|
},
|
||||||
let calledArgs: Parameters<ExecFileFn> = ["", [], () => {}];
|
);
|
||||||
mockExecFile = (cmd, args, callback) => {
|
|
||||||
calledArgs = [cmd, args, callback];
|
|
||||||
callback(null, "output-data", "");
|
|
||||||
};
|
|
||||||
const filePath = makeTempFile("binary placeholder content", "epub");
|
|
||||||
await convert(filePath, "epub", "pdf", "output.pdf", undefined, mockExecFile);
|
|
||||||
assertCJKFontArg(calledArgs[1], "Noto Sans CJK SC");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should always add CJK font for odt binary format", async () => {
|
|
||||||
let calledArgs: Parameters<ExecFileFn> = ["", [], () => {}];
|
|
||||||
mockExecFile = (cmd, args, callback) => {
|
|
||||||
calledArgs = [cmd, args, callback];
|
|
||||||
callback(null, "output-data", "");
|
|
||||||
};
|
|
||||||
const filePath = makeTempFile("binary placeholder content", "odt");
|
|
||||||
await convert(filePath, "odt", "pdf", "output.pdf", undefined, mockExecFile);
|
|
||||||
assertCJKFontArg(calledArgs[1], "Noto Sans CJK SC");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should reject if execFile returns an error", async () => {
|
test("should reject if execFile returns an error", async () => {
|
||||||
const filePath = makeTempFile("# Test\n");
|
const filePath = makeTempFile("# Test\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue