test: guard extension provider mock calls · openclaw/openclaw@b3ded35
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -64,7 +64,7 @@ describe("Google Meet OAuth", () => {
|
64 | 64 | expect(tokens.tokenType).toBe("Bearer"); |
65 | 65 | expect(Number.isFinite(tokens.expiresAt)).toBe(true); |
66 | 66 | expect(tokens.expiresAt).toBeGreaterThan(Date.now()); |
67 | | -const body = fetchMock.mock.calls[0]?.[1]?.body; |
| 67 | +const body = fetchMock.mock.calls.at(0)?.[1]?.body; |
68 | 68 | expect(body).toBeInstanceOf(URLSearchParams); |
69 | 69 | const params = body as URLSearchParams; |
70 | 70 | expect(params.get("grant_type")).toBe("refresh_token"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -52,7 +52,7 @@ function fetchRequest(fetchMock: ReturnType<typeof vi.fn>): {
|
52 | 52 | method?: string; |
53 | 53 | url: string; |
54 | 54 | } { |
55 | | -const [url, init] = fetchMock.mock.calls[0] as [string, RequestInit | undefined]; |
| 55 | +const [url, init] = fetchMock.mock.calls.at(0) as [string, RequestInit | undefined]; |
56 | 56 | expect(typeof url).toBe("string"); |
57 | 57 | if (!init) { |
58 | 58 | throw new Error("Expected fetch init"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -287,7 +287,7 @@ describe("google video generation provider", () => {
|
287 | 287 | durationSeconds: 3, |
288 | 288 | }); |
289 | 289 | |
290 | | -const [{ downloadPath }] = downloadMock.mock.calls[0] ?? [{}]; |
| 290 | +const [{ downloadPath }] = downloadMock.mock.calls.at(0) ?? [{}]; |
291 | 291 | const downloadBaseName = path.basename(String(downloadPath)); |
292 | 292 | expect(downloadBaseName).toContain("video-1.mp4"); |
293 | 293 | expect(downloadBaseName).toMatch(/\.part$/); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -119,7 +119,7 @@ describe("gradium tts diagnostics", () => {
|
119 | 119 | }); |
120 | 120 | |
121 | 121 | expect(fetchMock).toHaveBeenCalledOnce(); |
122 | | -const [url, init] = fetchMock.mock.calls[0] as [string, RequestInit]; |
| 122 | +const [url, init] = fetchMock.mock.calls.at(0) as [string, RequestInit]; |
123 | 123 | expect(url).toBe("https://api.gradium.ai/api/post/speech/tts"); |
124 | 124 | expect(init.method).toBe("POST"); |
125 | 125 | const headers = new Headers(init.headers); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -203,7 +203,7 @@ describe("imessage message actions", () => {
|
203 | 203 | ).rejects.toThrow(/imsg private API bridge/); |
204 | 204 | |
205 | 205 | expect(loggerMock.warn).toHaveBeenCalledTimes(1); |
206 | | -const warnArg = String(loggerMock.warn.mock.calls[0][0]); |
| 206 | +const warnArg = String(loggerMock.warn.mock.calls.at(0)?.[0]); |
207 | 207 | expect(warnArg).toMatch(/iMessage react blocked: private API bridge unavailable/); |
208 | 208 | expect(warnArg).toMatch(/imsg launch/); |
209 | 209 | expect(runtimeMock.sendReaction).not.toHaveBeenCalled(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -196,7 +196,7 @@ describe("irc inbound behavior", () => {
|
196 | 196 | |
197 | 197 | const assembledRequest = ( |
198 | 198 | coreRuntime.channel.turn.runAssembled as unknown as { mock: { calls: unknown[][] } } |
199 | | -).mock.calls[0]?.[0] as { replyPipeline?: unknown } | undefined; |
| 199 | +).mock.calls.at(0)?.[0] as { replyPipeline?: unknown } | undefined; |
200 | 200 | expect(assembledRequest?.replyPipeline).toEqual({}); |
201 | 201 | }); |
202 | 202 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -51,7 +51,7 @@ type WebhookRegistration = {
|
51 | 51 | }; |
52 | 52 | |
53 | 53 | function requireWebhookRegistration(): WebhookRegistration { |
54 | | -const registration = registerWebhookTargetWithPluginRouteMock.mock.calls[0]?.[0] as |
| 54 | +const registration = registerWebhookTargetWithPluginRouteMock.mock.calls.at(0)?.[0] as |
55 | 55 | | WebhookRegistration |
56 | 56 | | undefined; |
57 | 57 | if (!registration) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -418,7 +418,7 @@ describe("LINE send helpers", () => {
|
418 | 418 | ); |
419 | 419 | |
420 | 420 | expect(pushMessageMock).toHaveBeenCalledTimes(1); |
421 | | -const firstCall = pushMessageMock.mock.calls[0] as [ |
| 421 | +const firstCall = pushMessageMock.mock.calls.at(0) as [ |
422 | 422 | { messages: Array<{ quickReply?: { items: unknown[] } }> }, |
423 | 423 | ]; |
424 | 424 | expect(firstCall[0].messages[0].quickReply?.items).toHaveLength(13); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -26,7 +26,7 @@ describe("validateLineSignature", () => {
|
26 | 26 | expect(validateLineSignature(body, "short", secret)).toBe(false); |
27 | 27 | expect(spy).toHaveBeenCalledTimes(1); |
28 | 28 | |
29 | | -const [left, right] = spy.mock.calls[0] ?? []; |
| 29 | +const [left, right] = spy.mock.calls.at(0) ?? []; |
30 | 30 | expect(left).toBeInstanceOf(Buffer); |
31 | 31 | expect(right).toBeInstanceOf(Buffer); |
32 | 32 | expect(left?.byteLength).toBe(right?.byteLength); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -193,7 +193,7 @@ describe("litellm image generation provider", () => {
|
193 | 193 | }); |
194 | 194 | |
195 | 195 | expect(mockObjectArg(postJsonRequestMock).url).toBe("http://localhost:4000/images/edits"); |
196 | | -const call = postJsonRequestMock.mock.calls[0][0] as { body: { images: unknown[] } }; |
| 196 | +const call = postJsonRequestMock.mock.calls.at(0)?.[0] as { body: { images: unknown[] } }; |
197 | 197 | expect(call.body.images).toHaveLength(1); |
198 | 198 | }); |
199 | 199 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。