From f161f682405768cc988dc6c2840b1528615cbe2b Mon Sep 17 00:00:00 2001 From: Ryo Date: Thu, 2 Jul 2026 10:50:01 +0800 Subject: [PATCH] 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. --- tests/converters/pandoc.test.ts | 45 ++++++++++----------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/tests/converters/pandoc.test.ts b/tests/converters/pandoc.test.ts index 22d2960..a37301d 100644 --- a/tests/converters/pandoc.test.ts +++ b/tests/converters/pandoc.test.ts @@ -169,38 +169,19 @@ describe("convert", () => { expect(calledArgs[1].some((arg) => arg.startsWith("CJKmainfont"))).toBe(false); }); - test("should always add CJK font for docx binary format with -V adjacency", async () => { - let calledArgs: Parameters = ["", [], () => {}]; - mockExecFile = (cmd, args, callback) => { - calledArgs = [cmd, args, callback]; - callback(null, "output-data", ""); - }; - const filePath = makeTempFile("binary placeholder content", "docx"); - await convert(filePath, "docx", "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 = ["", [], () => {}]; - 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 = ["", [], () => {}]; - 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.each(["docx", "epub", "odt"])( + "should always add CJK font for %s binary format with -V adjacency", + async (format: string) => { + let calledArgs: Parameters = ["", [], () => {}]; + mockExecFile = (cmd, args, callback) => { + calledArgs = [cmd, args, callback]; + callback(null, "output-data", ""); + }; + 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 reject if execFile returns an error", async () => { const filePath = makeTempFile("# Test\n");