test: dedupe command helper mock reads · openclaw/openclaw@5ad3f7a
steipete
·
2026-05-13
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -369,7 +369,7 @@ describe("deliverAgentCommandResult", () => {
|
369 | 369 | |
370 | 370 | expect(runtime.log).toHaveBeenCalledTimes(1); |
371 | 371 | expect( |
372 | | -JSON.parse(String((runtime.log as ReturnType<typeof vi.fn>).mock.calls.at(0)?.[0])), |
| 372 | +JSON.parse(String((runtime.log as ReturnType<typeof vi.fn>).mock.calls[0]?.[0])), |
373 | 373 | ).toEqual({ |
374 | 374 | payloads: [ |
375 | 375 | { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -64,7 +64,7 @@ async function withTempHome<T>(fn: (home: string) => Promise<T>): Promise<T> {
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function requireResolveCommandConfigParams(callIndex = 0): ResolveCommandConfigParams { |
67 | | -const call = resolveCommandConfigWithSecretsMock.mock.calls.at(callIndex); |
| 67 | +const call = resolveCommandConfigWithSecretsMock.mock.calls[callIndex]; |
68 | 68 | if (!call) { |
69 | 69 | throw new Error(`expected command config resolution call ${callIndex}`); |
70 | 70 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -639,7 +639,7 @@ describe("applyAuthChoice", () => {
|
639 | 639 | expect(promptMessages(mock)).toContain(expected); |
640 | 640 | } |
641 | 641 | function firstCallArg(mock: { mock: { calls: unknown[][] } }): unknown { |
642 | | -const call = mock.mock.calls.at(0); |
| 642 | +const call = mock.mock.calls[0]; |
643 | 643 | if (!call) { |
644 | 644 | throw new Error("Expected first mock call"); |
645 | 645 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -211,7 +211,7 @@ function makeRuntime(): RuntimeEnv {
|
211 | 211 | } |
212 | 212 | |
213 | 213 | function promptModelAllowlistOptions(index = 0) { |
214 | | -return mocks.promptModelAllowlist.mock.calls.at(index)?.at(0) as |
| 214 | +return mocks.promptModelAllowlist.mock.calls[index]?.[0] as |
215 | 215 | | { |
216 | 216 | allowedKeys?: string[]; |
217 | 217 | initialSelections?: string[]; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -307,7 +307,7 @@ describe("maybeRepairGatewayDaemon", () => {
|
307 | 307 | }); |
308 | 308 | |
309 | 309 | expect(readGatewayRestartHandoffSync).toHaveBeenCalledOnce(); |
310 | | -const [handoffEnv] = readGatewayRestartHandoffSync.mock.calls.at(0) as unknown as [ |
| 310 | +const [handoffEnv] = readGatewayRestartHandoffSync.mock.calls[0] as unknown as [ |
311 | 311 | { OPENCLAW_STATE_DIR?: string; OPENCLAW_CONFIG_PATH?: string }, |
312 | 312 | ]; |
313 | 313 | expect(handoffEnv?.OPENCLAW_STATE_DIR).toBe("/tmp/openclaw-service"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -202,7 +202,7 @@ function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
202 | 202 | } |
203 | 203 | |
204 | 204 | function callArg(mock: { mock: { calls: Array<Array<unknown>> } }, index: number, label: string) { |
205 | | -const call = mock.mock.calls.at(index); |
| 205 | +const call = mock.mock.calls[index]; |
206 | 206 | if (!call) { |
207 | 207 | throw new Error(`Expected mock call: ${label}`); |
208 | 208 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -226,7 +226,7 @@ type MigrationSelectionPrompt = {
|
226 | 226 | }; |
227 | 227 | |
228 | 228 | function mockCall(source: MockCallSource, callIndex = 0): ReadonlyArray<unknown> { |
229 | | -const call = source.mock.calls.at(callIndex); |
| 229 | +const call = source.mock.calls[callIndex]; |
230 | 230 | if (!call) { |
231 | 231 | throw new Error(`Expected mock call ${callIndex}`); |
232 | 232 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -182,7 +182,7 @@ function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
182 | 182 | } |
183 | 183 | |
184 | 184 | function mockArg(source: MockCallSource, callIndex: number, argIndex: number, label: string) { |
185 | | -const call = source.mock.calls.at(callIndex); |
| 185 | +const call = source.mock.calls[callIndex]; |
186 | 186 | if (!call) { |
187 | 187 | throw new Error(`expected mock call: ${label}`); |
188 | 188 | } |
@@ -617,7 +617,7 @@ describe("promptDefaultModel", () => {
|
617 | 617 | expect(result.model).toBe("openai-codex/gpt-5.5-pro"); |
618 | 618 | expect(loadModelCatalog).toHaveBeenCalledOnce(); |
619 | 619 | expect(select).toHaveBeenCalledTimes(2); |
620 | | -expect(select.mock.calls.at(1)?.[0]?.searchable).toBe(true); |
| 620 | +expect(select.mock.calls[1]?.[0]?.searchable).toBe(true); |
621 | 621 | }); |
622 | 622 | |
623 | 623 | it("supports configuring vLLM during setup", async () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。