test: guard embedded subscribe mock calls · openclaw/openclaw@ee40b9b
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -438,7 +438,7 @@ describe("streamWithIdleTimeout", () => {
|
438 | 438 | expect(error).toBeInstanceOf(Error); |
439 | 439 | expect((error as Error).message).toMatch(/LLM idle timeout/); |
440 | 440 | expect(onIdleTimeout).toHaveBeenCalledTimes(1); |
441 | | -const [timeoutError] = onIdleTimeout.mock.calls[0] ?? []; |
| 441 | +const [timeoutError] = onIdleTimeout.mock.calls.at(0) ?? []; |
442 | 442 | expect(timeoutError).toBeInstanceOf(Error); |
443 | 443 | expect((timeoutError as Error).message).toMatch(/LLM idle timeout/); |
444 | 444 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -179,7 +179,7 @@ describe("handleToolExecutionStart read path checks", () => {
|
179 | 179 | await handleToolExecutionStart(ctx, evt); |
180 | 180 | |
181 | 181 | expect(warn).toHaveBeenCalledTimes(1); |
182 | | -expect(String(warn.mock.calls[0]?.[0] ?? "")).toContain("read tool called without path"); |
| 182 | +expect(String(warn.mock.calls.at(0)?.[0] ?? "")).toContain("read tool called without path"); |
183 | 183 | }); |
184 | 184 | |
185 | 185 | it("awaits onBlockReplyFlush before continuing tool start processing", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -22,7 +22,7 @@ describe("subscribeEmbeddedPiSession", () => {
|
22 | 22 | await Promise.resolve(); |
23 | 23 | |
24 | 24 | expect(onToolResult).toHaveBeenCalledTimes(1); |
25 | | -const payload = onToolResult.mock.calls[0][0]; |
| 25 | +const payload = onToolResult.mock.calls.at(0)?.[0]; |
26 | 26 | expect(payload.text).toContain("🖼️"); |
27 | 27 | expect(payload.text).toContain("Canvas"); |
28 | 28 | expect(payload.text).toContain("/tmp/a2ui.jsonl"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -34,6 +34,6 @@ describe("subscribeEmbeddedPiSession", () => {
|
34 | 34 | emitAssistantTextDeltaAndEnd({ emit, text }); |
35 | 35 | |
36 | 36 | expect(onBlockReply).toHaveBeenCalledTimes(3); |
37 | | -expect(onBlockReply.mock.calls[1][0].text).toBe("~~~sh\nline1\nline2\n~~~"); |
| 37 | +expect(onBlockReply.mock.calls.at(1)?.[0].text).toBe("~~~sh\nline1\nline2\n~~~"); |
38 | 38 | }); |
39 | 39 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -249,7 +249,7 @@ describe("subscribeEmbeddedPiSession", () => {
|
249 | 249 | await flushBlockReplyCallbacks(); |
250 | 250 | |
251 | 251 | expect(onBlockReply).toHaveBeenCalledTimes(1); |
252 | | -expect(onBlockReply.mock.calls[0][0].text).toBe("Final answer"); |
| 252 | +expect(onBlockReply.mock.calls.at(0)?.[0].text).toBe("Final answer"); |
253 | 253 | |
254 | 254 | const streamTexts = onReasoningStream.mock.calls |
255 | 255 | .map((call) => call[0]?.text) |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。