test(extensions): type mocked calls explicitly · openclaw/openclaw@f142bb0
Kaspre
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -114,10 +114,11 @@ describe("openrouter image generation provider", () => {
|
114 | 114 | providers: { |
115 | 115 | openrouter: { |
116 | 116 | baseUrl: "https://custom.openrouter.test/api/v1", |
| 117 | +models: [], |
117 | 118 | }, |
118 | 119 | }, |
119 | 120 | }, |
120 | | -} as never, |
| 121 | +}, |
121 | 122 | }); |
122 | 123 | |
123 | 124 | expect(resolveApiKeyForProviderMock).toHaveBeenCalledOnce(); |
@@ -219,7 +220,7 @@ describe("openrouter image generation provider", () => {
|
219 | 220 | model: "google/gemini-3.1-flash-image-preview", |
220 | 221 | prompt: "turn this into watercolor", |
221 | 222 | inputImages: [{ buffer: Buffer.from("source-image"), mimeType: "image/png" }], |
222 | | -cfg: {} as never, |
| 223 | +cfg: {}, |
223 | 224 | }); |
224 | 225 | |
225 | 226 | const body = requireOpenRouterPostBody(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,23 +3,23 @@ import { describe, expect, it, vi } from "vitest";
|
3 | 3 | describe("zca-client runtime loading", () => { |
4 | 4 | it("does not import zca-js until a session is created", async () => { |
5 | 5 | vi.clearAllMocks(); |
| 6 | +let constructedOptions: { logging?: boolean; selfListen?: boolean } | undefined; |
| 7 | +function MockZalo(options?: { logging?: boolean; selfListen?: boolean }) { |
| 8 | +constructedOptions = options; |
| 9 | +} |
6 | 10 | const runtimeFactory = vi.fn(() => ({ |
7 | | -Zalo: class MockZalo { |
8 | | -constructor(public readonly options?: { logging?: boolean; selfListen?: boolean }) {} |
9 | | -}, |
| 11 | +Zalo: MockZalo, |
10 | 12 | })); |
11 | 13 | |
12 | 14 | vi.doMock("zca-js", runtimeFactory); |
13 | 15 | |
14 | 16 | const zcaClient = await import("./zca-client.js"); |
15 | 17 | expect(runtimeFactory).not.toHaveBeenCalled(); |
16 | 18 | |
17 | | -const client = (await zcaClient.createZalo({ logging: false, selfListen: true })) as { |
18 | | -options?: { logging?: boolean; selfListen?: boolean }; |
19 | | -}; |
| 19 | +await zcaClient.createZalo({ logging: false, selfListen: true }); |
20 | 20 | |
21 | 21 | expect(runtimeFactory).toHaveBeenCalledTimes(1); |
22 | | -expect((client as { options?: { logging?: boolean; selfListen?: boolean } }).options).toEqual({ |
| 22 | +expect(constructedOptions).toEqual({ |
23 | 23 | logging: false, |
24 | 24 | selfListen: true, |
25 | 25 | }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。