From b635ff751e53cb661016fe63d4ab32bd684f8c6d Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Thu, 3 Dec 2026 19:29:03 +0800 Subject: [PATCH] test(cli): share timing flag fixture matrix (#16327) --- tests/boundary/cli/cliTimingArguments.test.ts | 90 ++++++++----------- 1 file changed, 35 insertions(+), 55 deletions(-) diff --git a/tests/boundary/cli/cliTimingArguments.test.ts b/tests/boundary/cli/cliTimingArguments.test.ts index e0453a61997..2f1e305bc59 100644 --- a/tests/boundary/cli/cliTimingArguments.test.ts +++ b/tests/boundary/cli/cliTimingArguments.test.ts @@ -4,6 +4,15 @@ import { parseCliGlobalArguments, } from "../../../src/cliBuiltinArguments.js"; +const timingFlags = [ + ["--timings", true], + ["--no-timings", false], + ["--timings=false", false], + ["--timings=true", true], + ["--timings=other", false], + ["--timings=", false], +] as const; + // Observed with Incur 0.6.1 before removing the dependency. it.each([ { @@ -11,36 +20,11 @@ it.each([ rest: [], enabled: false, }, - { - input: ["--timings"], + ...timingFlags.map(([flag, enabled]) => ({ + input: [flag], rest: [], - enabled: true, - }, - { - input: ["--no-timings"], - rest: [], - enabled: false, - }, - { - input: ["--timings=false"], - rest: [], - enabled: false, - }, - { - input: ["--timings=true"], - rest: [], - enabled: true, - }, - { - input: ["--timings=other"], - rest: [], - enabled: false, - }, - { - input: ["--timings="], - rest: [], - enabled: false, - }, + enabled, + })), { input: ["--timings", "--no-timings"], rest: [], @@ -72,32 +56,28 @@ it.each([ }, ); -it.each([ - "--timings", - "--no-timings", - "--timings=false", - "--timings=true", - "--timings=other", - "--timings=", -])("preserves output values and root alias with %s", (flag) => { - expect( - classifyCliEntrypoint(["mcp", "doctor", "--format", flag], {}), - ).toEqual({ - kind: "mcp-doctor", - arguments: ["--format", flag], - timings: false, - }); - expect( - parseCliGlobalArguments([flag, "--update", "--json"]).arguments, - ).toEqual(["update", flag, "--json"]); - expect( - parseCliGlobalArguments(["--update", flag, "--json"]).arguments, - ).toEqual(["update", flag, "--json"]); - expect(parseCliGlobalArguments([flag, "mcp", "doctor"]).command).toEqual([ - "mcp", - "doctor", - ]); -}); +it.each(timingFlags.map(([flag]) => flag))( + "preserves output values and root alias with %s", + (flag) => { + expect( + classifyCliEntrypoint(["mcp", "doctor", "--format", flag], {}), + ).toEqual({ + kind: "mcp-doctor", + arguments: ["--format", flag], + timings: false, + }); + expect( + parseCliGlobalArguments([flag, "--update", "--json"]).arguments, + ).toEqual(["update", flag, "--json"]); + expect( + parseCliGlobalArguments(["--update", flag, "--json"]).arguments, + ).toEqual(["update", flag, "--json"]); + expect(parseCliGlobalArguments([flag, "mcp", "doctor"]).command).toEqual([ + "mcp", + "doctor", + ]); + }, +); it("retains the separator and its following timing-shaped data", () => { expect( parseCliGlobalArguments(["--", "--update", "--timings=false"]).arguments,