fix: local updates for PR #4780
Co-authored-by: jlowin <jlowin@users.noreply.github.com>
This commit is contained in:
committed by
Gustavo Madeira Santana
parent
dd4715a2c4
commit
f24e3cdae5
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const githubCopilotLoginCommand = vi.fn();
|
||||
const modelsStatusCommand = vi.fn().mockResolvedValue(undefined);
|
||||
|
||||
vi.mock("../commands/models.js", async () => {
|
||||
const actual = (await vi.importActual<typeof import("../commands/models.js")>(
|
||||
@@ -10,10 +11,16 @@ vi.mock("../commands/models.js", async () => {
|
||||
return {
|
||||
...actual,
|
||||
githubCopilotLoginCommand,
|
||||
modelsStatusCommand,
|
||||
};
|
||||
});
|
||||
|
||||
describe("models cli", () => {
|
||||
beforeEach(() => {
|
||||
githubCopilotLoginCommand.mockClear();
|
||||
modelsStatusCommand.mockClear();
|
||||
});
|
||||
|
||||
it("registers github-copilot login command", { timeout: 60_000 }, async () => {
|
||||
const { Command } = await import("commander");
|
||||
const { registerModelsCli } = await import("./models-cli.js");
|
||||
@@ -40,4 +47,51 @@ describe("models cli", () => {
|
||||
expect.any(Object),
|
||||
);
|
||||
});
|
||||
|
||||
it("passes --agent to models status", async () => {
|
||||
const { Command } = await import("commander");
|
||||
const { registerModelsCli } = await import("./models-cli.js");
|
||||
|
||||
const program = new Command();
|
||||
registerModelsCli(program);
|
||||
|
||||
await program.parseAsync(["models", "status", "--agent", "poe"], { from: "user" });
|
||||
|
||||
expect(modelsStatusCommand).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ agent: "poe" }),
|
||||
expect.any(Object),
|
||||
);
|
||||
});
|
||||
|
||||
it("passes parent --agent to models status", async () => {
|
||||
const { Command } = await import("commander");
|
||||
const { registerModelsCli } = await import("./models-cli.js");
|
||||
|
||||
const program = new Command();
|
||||
registerModelsCli(program);
|
||||
|
||||
await program.parseAsync(["models", "--agent", "poe", "status"], { from: "user" });
|
||||
|
||||
expect(modelsStatusCommand).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ agent: "poe" }),
|
||||
expect.any(Object),
|
||||
);
|
||||
});
|
||||
|
||||
it("shows help for models auth without error exit", async () => {
|
||||
const { Command } = await import("commander");
|
||||
const { registerModelsCli } = await import("./models-cli.js");
|
||||
|
||||
const program = new Command();
|
||||
program.exitOverride();
|
||||
registerModelsCli(program);
|
||||
|
||||
try {
|
||||
await program.parseAsync(["models", "auth"], { from: "user" });
|
||||
expect.fail("expected help to exit");
|
||||
} catch (err) {
|
||||
const error = err as { exitCode?: number };
|
||||
expect(error.exitCode).toBe(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user