test: invoke captured test callbacks · openclaw/openclaw@11d0c5e
steipete
·
2026-05-08
·
via Recent Commits to openclaw:main
File tree
agents/pi-embedded-runner
| Original file line number | Diff line number | Diff line change |
|---|
@@ -26,7 +26,9 @@ function applyAndExpectWrapped(params: {
|
26 | 26 | params.model, |
27 | 27 | ); |
28 | 28 | |
29 | | -expect(agent.streamFn).toEqual(expect.any(Function)); |
| 29 | +if (!agent.streamFn) { |
| 30 | +throw new Error("expected extra params to wrap streamFn"); |
| 31 | +} |
30 | 32 | } |
31 | 33 | |
32 | 34 | // Mock the logger to avoid noise in tests |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -236,7 +236,9 @@ describe("withReplyDispatcher", () => {
|
236 | 236 | }); |
237 | 237 | |
238 | 238 | const dispatcherOptions = hoisted.createReplyDispatcherMock.mock.calls[0]?.[0]; |
239 | | -expect(dispatcherOptions?.beforeDeliver).toEqual(expect.any(Function)); |
| 239 | +if (!dispatcherOptions?.beforeDeliver) { |
| 240 | +throw new Error("expected beforeDeliver hook"); |
| 241 | +} |
240 | 242 | |
241 | 243 | const payload = await dispatcherOptions.beforeDeliver( |
242 | 244 | { text: "original reply" }, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -537,8 +537,10 @@ describe("describeImageWithModel", () => {
|
537 | 537 | }); |
538 | 538 | expect(completeMock).toHaveBeenCalledTimes(2); |
539 | 539 | const [, , retryOptions] = completeMock.mock.calls[1] ?? []; |
540 | | -expect(retryOptions?.onPayload).toEqual(expect.any(Function)); |
541 | | -const retryPayload = await retryOptions?.onPayload?.( |
| 540 | +if (!retryOptions?.onPayload) { |
| 541 | +throw new Error("expected retry payload mapper"); |
| 542 | +} |
| 543 | +const retryPayload = await retryOptions.onPayload( |
542 | 544 | { |
543 | 545 | reasoning: { effort: "high", summary: "auto" }, |
544 | 546 | reasoning_effort: "high", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -519,7 +519,7 @@ describe("plugin-sdk root alias", () => {
|
519 | 519 | throw new Error("expected onDiagnosticEvent export"); |
520 | 520 | } |
521 | 521 | const unsubscribe = (value as (listener: () => void) => () => void)(() => undefined); |
522 | | -expect(unsubscribe).toEqual(expect.any(Function)); |
| 522 | +unsubscribe(); |
523 | 523 | }, |
524 | 524 | }, |
525 | 525 | ])("$name", ({ exportName, exportValue, expectIdentity, assertForwarded }) => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -493,7 +493,10 @@ describe("plugin interactive handlers", () => {
|
493 | 493 | inflightCallbackDedupe?: Set<string>; |
494 | 494 | }; |
495 | 495 | expect(hydrated.interactiveHandlers).toBeInstanceOf(Map); |
496 | | -expect(hydrated.callbackDedupe?.clear).toEqual(expect.any(Function)); |
| 496 | +if (!hydrated.callbackDedupe) { |
| 497 | +throw new Error("expected hydrated callback dedupe"); |
| 498 | +} |
| 499 | +expect(() => hydrated.callbackDedupe?.clear()).not.toThrow(); |
497 | 500 | expect(hydrated.inflightCallbackDedupe).toBeInstanceOf(Set); |
498 | 501 | |
499 | 502 | const handler = vi.fn(async () => ({ handled: true })); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。