test: guard zalo startup mock calls · openclaw/openclaw@3b15e11
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -69,6 +69,15 @@ function buildAccount(): ResolvedZaloAccount {
|
69 | 69 | }; |
70 | 70 | } |
71 | 71 | |
| 72 | +function requireMonitorArgs() { |
| 73 | +const [call] = hoisted.monitorZaloProvider.mock.calls; |
| 74 | +if (!call) { |
| 75 | +throw new Error("expected Zalo monitor call"); |
| 76 | +} |
| 77 | +const [monitorArgs] = call; |
| 78 | +return monitorArgs; |
| 79 | +} |
| 80 | + |
72 | 81 | describe("zaloPlugin gateway.startAccount", () => { |
73 | 82 | afterEach(() => { |
74 | 83 | vi.clearAllMocks(); |
@@ -101,7 +110,7 @@ describe("zaloPlugin gateway.startAccount", () => {
|
101 | 110 | expectLifecyclePatch(patches, { accountId: "default" }); |
102 | 111 | expect(isSettled()).toBe(true); |
103 | 112 | expect(hoisted.monitorZaloProvider).toHaveBeenCalledTimes(1); |
104 | | -const [monitorArgs] = hoisted.monitorZaloProvider.mock.calls[0] ?? []; |
| 113 | +const monitorArgs = requireMonitorArgs(); |
105 | 114 | expect(monitorArgs).toStrictEqual({ |
106 | 115 | token: "test-token", |
107 | 116 | account: buildAccount(), |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。