test: guard signal helper assertions · openclaw/openclaw@1998386
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -95,12 +95,16 @@ function expectRpcCall(params: {
|
95 | 95 | if (params.rpcParams) { |
96 | 96 | expectFields(requireRecord(rpcParams, "rpc params"), params.rpcParams); |
97 | 97 | } else { |
98 | | -expect(rpcParams).toBeDefined(); |
| 98 | +if (rpcParams === undefined) { |
| 99 | +throw new Error("expected rpc params argument"); |
| 100 | +} |
99 | 101 | } |
100 | 102 | if (params.options) { |
101 | 103 | expectFields(requireRecord(options, "rpc options"), params.options); |
102 | 104 | } else { |
103 | | -expect(options).toBeDefined(); |
| 105 | +if (options === undefined) { |
| 106 | +throw new Error("expected rpc options argument"); |
| 107 | +} |
104 | 108 | } |
105 | 109 | } |
106 | 110 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -288,7 +288,9 @@ describe("containerRestRequest", () => {
|
288 | 288 | |
289 | 289 | // The timeout is enforced via AbortController, so we verify the call was made with a signal |
290 | 290 | expect(mockFetch).toHaveBeenCalled(); |
291 | | -expect(requireFetchCall()[1].signal).toBeDefined(); |
| 291 | +if (requireFetchCall()[1].signal === undefined) { |
| 292 | +throw new Error("expected fetch call to include an abort signal"); |
| 293 | +} |
292 | 294 | }); |
293 | 295 | }); |
294 | 296 | |
@@ -428,7 +430,9 @@ describe("containerSendMessage", () => {
|
428 | 430 | const callArgs = mockFetch.mock.calls[0]; |
429 | 431 | const body = JSON.parse(callArgs[1].body); |
430 | 432 | expect(body.attachments).toBeUndefined(); |
431 | | -expect(body.base64_attachments).toBeDefined(); |
| 433 | +if (!Array.isArray(body.base64_attachments)) { |
| 434 | +throw new Error("expected base64 attachments array"); |
| 435 | +} |
432 | 436 | expect(body.base64_attachments).toHaveLength(1); |
433 | 437 | expect(body.base64_attachments[0]).toMatch( |
434 | 438 | /^data:image\/jpeg;filename=test-image\.jpg;base64,/, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。