mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 22:35:51 +00:00
- 新增 tests/mocks/log.ts 和 tests/mocks/debug.ts,覆盖源文件全部实际导出 - 移除旧 mock 中不存在的导出(logToFile、logEvent、getLogFilePath) - 13 个测试文件改为使用共享 mock,避免定义分散和不一致 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { mock, describe, expect, test, afterEach } from "bun:test";
|
|
import { debugMock } from "../../../../tests/mocks/debug";
|
|
|
|
mock.module("axios", () => ({
|
|
default: { get: async () => ({ data: { servers: [] } }) },
|
|
}));
|
|
mock.module("src/utils/debug.ts", debugMock);
|
|
|
|
const { isOfficialMcpUrl, resetOfficialMcpUrlsForTesting } = await import(
|
|
"../officialRegistry"
|
|
);
|
|
|
|
describe("isOfficialMcpUrl", () => {
|
|
afterEach(() => {
|
|
resetOfficialMcpUrlsForTesting();
|
|
});
|
|
|
|
test("returns false when registry not loaded (initial state)", () => {
|
|
resetOfficialMcpUrlsForTesting();
|
|
expect(isOfficialMcpUrl("https://example.com")).toBe(false);
|
|
});
|
|
|
|
test("returns false for non-registered URL", () => {
|
|
expect(isOfficialMcpUrl("https://random-server.com/mcp")).toBe(false);
|
|
});
|
|
|
|
test("returns false for empty string", () => {
|
|
expect(isOfficialMcpUrl("")).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("resetOfficialMcpUrlsForTesting", () => {
|
|
test("can be called without error", () => {
|
|
expect(() => resetOfficialMcpUrlsForTesting()).not.toThrow();
|
|
});
|
|
|
|
test("clears state so subsequent lookups return false", () => {
|
|
resetOfficialMcpUrlsForTesting();
|
|
expect(isOfficialMcpUrl("https://anything.com")).toBe(false);
|
|
});
|
|
});
|