test: guard signal ingest mock calls · openclaw/openclaw@065475d
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
File tree
extensions/signal/src/monitor
| Original file line number | Diff line number | Diff line change |
|---|
@@ -31,6 +31,14 @@ vi.mock("openclaw/plugin-sdk/hook-runtime", async () => {
|
31 | 31 | |
32 | 32 | import { createSignalEventHandler } from "./event-handler.js"; |
33 | 33 | |
| 34 | +function requireInternalHookEventCall() { |
| 35 | +const [call] = internalHookMocks.createInternalHookEvent.mock.calls; |
| 36 | +if (!call) { |
| 37 | +throw new Error("expected internal hook event call"); |
| 38 | +} |
| 39 | +return call; |
| 40 | +} |
| 41 | + |
34 | 42 | describe("signal mention-skip silent ingest", () => { |
35 | 43 | it("emits internal message:received when ingest is enabled", async () => { |
36 | 44 | internalHookMocks.createInternalHookEvent.mockClear(); |
@@ -67,8 +75,7 @@ describe("signal mention-skip silent ingest", () => {
|
67 | 75 | ); |
68 | 76 | |
69 | 77 | expect(internalHookMocks.createInternalHookEvent).toHaveBeenCalledTimes(1); |
70 | | -const [type, action, sessionKey, context] = |
71 | | -internalHookMocks.createInternalHookEvent.mock.calls[0] ?? []; |
| 78 | +const [type, action, sessionKey, context] = requireInternalHookEventCall(); |
72 | 79 | expect(type).toBe("message"); |
73 | 80 | expect(action).toBe("received"); |
74 | 81 | expect(sessionKey).toContain("signal"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。