refactor: centralize auth-choice model defaults

This commit is contained in:
Peter Steinberger
2026-01-13 05:24:41 +00:00
parent 0321d5ed74
commit 61b7398cb7
5 changed files with 238 additions and 179 deletions

View File

@@ -6,7 +6,11 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import type { RuntimeEnv } from "../runtime.js";
import type { WizardPrompter } from "../wizard/prompts.js";
import { applyAuthChoice } from "./auth-choice.js";
import {
applyAuthChoice,
resolvePreferredProviderForAuthChoice,
} from "./auth-choice.js";
import type { AuthChoice } from "./onboard-types.js";
vi.mock("../providers/github-copilot-auth.js", () => ({
githubCopilotLoginCommand: vi.fn(async () => {}),
@@ -444,3 +448,17 @@ describe("applyAuthChoice", () => {
});
});
});
describe("resolvePreferredProviderForAuthChoice", () => {
it("maps github-copilot to the provider", () => {
expect(resolvePreferredProviderForAuthChoice("github-copilot")).toBe(
"github-copilot",
);
});
it("returns undefined for unknown choices", () => {
expect(
resolvePreferredProviderForAuthChoice("unknown" as AuthChoice),
).toBeUndefined();
});
});