test: guard agent runtime mock calls · openclaw/openclaw@cb059e4
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -95,7 +95,7 @@ async function waitForAfterToolCall(hooks: {
|
95 | 95 | await vi.waitFor(() => { |
96 | 96 | expect(hooks.afterToolCall).toHaveBeenCalledTimes(1); |
97 | 97 | }); |
98 | | -const call = hooks.afterToolCall.mock.calls[0]; |
| 98 | +const call = hooks.afterToolCall.mock.calls.at(0); |
99 | 99 | if (!call) { |
100 | 100 | throw new Error("Expected afterToolCall hook call"); |
101 | 101 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -68,7 +68,7 @@ describe("Outcome/fallback runtime contract - Pi fallback classifier", () => {
|
68 | 68 | |
69 | 69 | expect(result.result).toBe(fallback); |
70 | 70 | expect(run).toHaveBeenCalledTimes(2); |
71 | | -expect(run.mock.calls[1]).toEqual([ |
| 71 | +expect(run.mock.calls.at(1)).toEqual([ |
72 | 72 | OUTCOME_FALLBACK_RUNTIME_CONTRACT.fallbackProvider, |
73 | 73 | OUTCOME_FALLBACK_RUNTIME_CONTRACT.fallbackModel, |
74 | 74 | ]); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -106,7 +106,7 @@ describe("bundle LSP runtime", () => {
|
106 | 106 | const runtime = await createBundleLspToolRuntime({ workspaceDir: "/tmp/workspace" }); |
107 | 107 | |
108 | 108 | expect(spawnMock).toHaveBeenCalledTimes(1); |
109 | | -const [command, args, options] = spawnMock.mock.calls[0] ?? []; |
| 109 | +const [command, args, options] = spawnMock.mock.calls.at(0) ?? []; |
110 | 110 | expect(command).toBe("typescript-language-server"); |
111 | 111 | expect(args).toEqual(["--stdio"]); |
112 | 112 | expect(options?.detached).toBe(process.platform !== "win32"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -172,7 +172,7 @@ describeLive("pi embedded anthropic replay sanitization (live)", () => {
|
172 | 172 | await Promise.resolve(wrapped(model as never, { messages } as never, {} as never)); |
173 | 173 | |
174 | 174 | expect(baseFn).toHaveBeenCalledTimes(1); |
175 | | -const seenMessages = (baseFn.mock.calls[0]?.[1] as { messages?: unknown[] })?.messages; |
| 175 | +const seenMessages = (baseFn.mock.calls.at(0)?.[1] as { messages?: unknown[] })?.messages; |
176 | 176 | expect(seenMessages).toEqual(messages); |
177 | 177 | |
178 | 178 | logLiveCache(`anthropic replay live model=${model.provider}/${model.id}`); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1222,7 +1222,7 @@ describe("runEmbeddedPiAgent auth profile rotation", () => {
|
1222 | 1222 | |
1223 | 1223 | expect(runEmbeddedAttemptMock).toHaveBeenCalledTimes(1); |
1224 | 1224 | const attemptParams = requireRecord( |
1225 | | -runEmbeddedAttemptMock.mock.calls[0]?.[0], |
| 1225 | +runEmbeddedAttemptMock.mock.calls.at(0)?.[0], |
1226 | 1226 | "embedded attempt params", |
1227 | 1227 | ); |
1228 | 1228 | expect(attemptParams.authProfileId).toBe("openai-codex:work"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。