


























@@ -55,6 +55,14 @@ function scanResult(overrides: Partial<ModelScanResult> = {}): ModelScanResult {
5555};
5656}
575758+function firstScanRequest(): { apiKey?: string; probe?: boolean } {
59+const call = mocks.scanOpenRouterModels.mock.calls[0];
60+if (!call) {
61+throw new Error("expected OpenRouter scan call");
62+}
63+return call[0] as { apiKey?: string; probe?: boolean };
64+}
65+5866describe("models scan command", () => {
5967beforeEach(() => {
6068vi.clearAllMocks();
@@ -73,7 +81,7 @@ describe("models scan command", () => {
7381expect(mocks.loadModelsConfig).not.toHaveBeenCalled();
7482expect(mocks.resolveApiKeyForProvider).not.toHaveBeenCalled();
7583expect(mocks.scanOpenRouterModels).toHaveBeenCalledTimes(1);
76-expect(mocks.scanOpenRouterModels.mock.calls.at(0)?.[0]?.probe).toBe(false);
84+expect(firstScanRequest().probe).toBe(false);
7785expect(runtime.lines.join("\n")).toContain("metadata only");
7886expect(runtime.lines.join("\n")).toContain("Tool");
7987expect(runtime.lines.join("\n")).toContain("skip");
@@ -94,7 +102,7 @@ describe("models scan command", () => {
94102cfg: {},
95103});
96104expect(mocks.scanOpenRouterModels).toHaveBeenCalledTimes(1);
97-expect(mocks.scanOpenRouterModels.mock.calls.at(0)?.[0]?.probe).toBe(false);
105+expect(firstScanRequest().probe).toBe(false);
98106expect(runtime.lines.join("\n")).toContain("still require OPENROUTER_API_KEY");
99107});
100108@@ -112,7 +120,7 @@ describe("models scan command", () => {
112120expect(mocks.loadModelsConfig).not.toHaveBeenCalled();
113121expect(mocks.resolveApiKeyForProvider).not.toHaveBeenCalled();
114122expect(mocks.scanOpenRouterModels).toHaveBeenCalledTimes(1);
115-const scanRequest = mocks.scanOpenRouterModels.mock.calls.at(0)?.[0];
123+const scanRequest = firstScanRequest();
116124expect(scanRequest?.apiKey).toBe("sk-or-test");
117125expect(scanRequest?.probe).toBe(true);
118126});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。