























@@ -106,6 +106,20 @@ describe("models cli", () => {
106106return command;
107107}
108108109+function expectCommandOptions(
110+command: ReturnType<typeof vi.fn>,
111+expected: Record<string, unknown>,
112+) {
113+expect(command).toHaveBeenCalledTimes(1);
114+const options = command.mock.calls[0]?.[0] as Record<string, unknown> | undefined;
115+const context = command.mock.calls[0]?.[1];
116+for (const [key, value] of Object.entries(expected)) {
117+expect(options?.[key]).toEqual(value);
118+}
119+expect(typeof context).toBe("object");
120+expect(context).not.toBeNull();
121+}
122+109123it("registers github-copilot login command", async () => {
110124const program = createProgram();
111125const models = requireCommand(program, "models");
@@ -118,26 +132,20 @@ describe("models cli", () => {
118132);
119133120134expect(modelsAuthLoginCommand).toHaveBeenCalledTimes(1);
121-expect(modelsAuthLoginCommand).toHaveBeenCalledWith(
122-expect.objectContaining({
123-provider: "github-copilot",
124-method: "device",
125-yes: true,
126-agent: "poe",
127-}),
128-expect.any(Object),
129-);
135+expectCommandOptions(modelsAuthLoginCommand, {
136+provider: "github-copilot",
137+method: "device",
138+yes: true,
139+agent: "poe",
140+});
130141});
131142132143it.each([
133144{ label: "status flag", args: ["models", "status", "--agent", "poe"] },
134145{ label: "parent flag", args: ["models", "--agent", "poe", "status"] },
135146])("passes --agent to models status ($label)", async ({ args }) => {
136147await runModelsCommand(args);
137-expect(modelsStatusCommand).toHaveBeenCalledWith(
138-expect.objectContaining({ agent: "poe" }),
139-expect.any(Object),
140-);
148+expectCommandOptions(modelsStatusCommand, { agent: "poe" });
141149});
142150143151it.each([
@@ -180,16 +188,13 @@ describe("models cli", () => {
180188])("passes parent --agent to models auth $label", async ({ args, command, expected }) => {
181189await runModelsCommand(args);
182190183-expect(command).toHaveBeenCalledWith(expect.objectContaining(expected), expect.any(Object));
191+expectCommandOptions(command, expected);
184192});
185193186194it("passes list-specific --agent and --json to models auth list", async () => {
187195await runModelsCommand(["models", "auth", "list", "--agent", "poe", "--json"]);
188196189-expect(modelsAuthListCommand).toHaveBeenCalledWith(
190-expect.objectContaining({ agent: "poe", json: true }),
191-expect.any(Object),
192-);
197+expectCommandOptions(modelsAuthListCommand, { agent: "poe", json: true });
193198});
194199195200it.each([
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。