Files
oh-my-pi/packages/ai/test/github-copilot-oauth.test.ts
T
can1357 9d457f73d9 test: migrated test imports to package subpath exports
- Replaced relative `../src` imports with `@oh-my-pi/pi-ai` and `@oh-my-pi/pi-agent-core` subpaths.
2026-06-08 19:03:55 +02:00

32 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "bun:test";
import {
getGitHubCopilotBaseUrl,
normalizeGitHubCopilotEnterpriseDomain,
parseGitHubCopilotApiKey,
} from "@oh-my-pi/pi-ai/registry/oauth/github-copilot";
describe("GitHub Copilot OAuth helpers", () => {
it("treats github.com as the public Copilot host", () => {
expect(normalizeGitHubCopilotEnterpriseDomain("github.com")).toBeUndefined();
expect(normalizeGitHubCopilotEnterpriseDomain("https://api.github.com")).toBeUndefined();
expect(getGitHubCopilotBaseUrl("github.com")).toBe("https://api.githubcopilot.com");
});
it("maps enterprise domains to the Copilot enterprise host", () => {
expect(normalizeGitHubCopilotEnterpriseDomain("https://ghe.example.com")).toBe("ghe.example.com");
expect(getGitHubCopilotBaseUrl("ghe.example.com")).toBe("https://copilot-api.ghe.example.com");
expect(getGitHubCopilotBaseUrl("copilot-api.ghe.example.com")).toBe("https://copilot-api.ghe.example.com");
});
it("parses structured Copilot api keys", () => {
expect(
parseGitHubCopilotApiKey(
JSON.stringify({ token: "ghu_test_token", enterpriseUrl: "https://ghe.example.com" }),
),
).toEqual({
accessToken: "ghu_test_token",
enterpriseUrl: "ghe.example.com",
});
});
});