test: guard extension callback captures · openclaw/openclaw@948ba9e
steipete
·
2026-05-08
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -290,8 +290,11 @@ describe("gateway bonjour advertiser", () => {
|
290 | 290 | |
291 | 291 | await started.stop(); |
292 | 292 | childProcessModule.exec('arp -a | findstr /C:"---"', () => {}); |
293 | | -const afterStopOptions = execMock.mock.calls.at(-1)?.[1]; |
294 | | -expect(afterStopOptions).toEqual(expect.any(Function)); |
| 293 | +const afterStopCallback = execMock.mock.calls.at(-1)?.[1]; |
| 294 | +if (typeof afterStopCallback !== "function") { |
| 295 | +throw new Error("expected restored exec callback overload"); |
| 296 | +} |
| 297 | +afterStopCallback(null, "", ""); |
295 | 298 | } finally { |
296 | 299 | childProcessModule.exec = originalExec; |
297 | 300 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2638,7 +2638,9 @@ describe("createTelegramBot", () => {
|
2638 | 2638 | createTelegramBot({ token: "tok" }); |
2639 | 2639 | const reactionHandler = onSpy.mock.calls.find((call) => call[0] === "message_reaction"); |
2640 | 2640 | expect(reactionHandler?.[0]).toBe("message_reaction"); |
2641 | | -expect(reactionHandler?.[1]).toEqual(expect.any(Function)); |
| 2641 | +if (typeof reactionHandler?.[1] !== "function") { |
| 2642 | +throw new Error("expected message_reaction handler"); |
| 2643 | +} |
2642 | 2644 | }); |
2643 | 2645 | |
2644 | 2646 | it("enqueues system event for reaction", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1206,13 +1206,16 @@ describe("RealtimeCallHandler websocket hardening", () => {
|
1206 | 1206 | }), |
1207 | 1207 | ); |
1208 | 1208 | await vi.waitFor(() => { |
1209 | | -expect(sendProviderAudio).toEqual(expect.any(Function)); |
| 1209 | +if (!sendProviderAudio) { |
| 1210 | +throw new Error("expected realtime provider audio sender"); |
| 1211 | +} |
1210 | 1212 | }); |
1211 | 1213 | |
1212 | | -if (!sendProviderAudio) { |
| 1214 | +const providerAudioSender = sendProviderAudio; |
| 1215 | +if (!providerAudioSender) { |
1213 | 1216 | throw new Error("expected realtime provider audio sender"); |
1214 | 1217 | } |
1215 | | -sendProviderAudio(Buffer.alloc(8_000 * 121, 0x7f)); |
| 1218 | +providerAudioSender(Buffer.alloc(8_000 * 121, 0x7f)); |
1216 | 1219 | const closed = await waitForClose(ws); |
1217 | 1220 | |
1218 | 1221 | expect(closed.code).toBe(1013); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。