test: guard respawn and image mock calls · openclaw/openclaw@b0946c1
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -19,6 +19,14 @@ function expectCliRespawnPlan(plan: ReturnType<typeof buildCliRespawnPlan>): Cli
|
19 | 19 | return plan; |
20 | 20 | } |
21 | 21 | |
| 22 | +function requireFirstMockCall(mock: { mock: { calls: unknown[][] } }, label: string): unknown[] { |
| 23 | +const [call] = mock.mock.calls; |
| 24 | +if (!call) { |
| 25 | +throw new Error(`expected ${label} call`); |
| 26 | +} |
| 27 | +return call; |
| 28 | +} |
| 29 | + |
22 | 30 | describe("buildCliRespawnPlan", () => { |
23 | 31 | it("returns null when respawn policy skips the argv", () => { |
24 | 32 | expect( |
@@ -185,9 +193,12 @@ describe("runCliRespawnPlan", () => {
|
185 | 193 | env: { OPENCLAW_NODE_OPTIONS_READY: "1" }, |
186 | 194 | }, |
187 | 195 | ); |
188 | | -expect(attachChildProcessBridge.mock.calls[0]?.[0]).toBe(child); |
189 | | -const bridgeOptions = attachChildProcessBridge.mock.calls[0]?.[1]; |
190 | | -expect(typeof bridgeOptions?.onSignal).toBe("function"); |
| 196 | +const [bridgeChild, bridgeOptions] = requireFirstMockCall( |
| 197 | +attachChildProcessBridge, |
| 198 | +"child process bridge attach", |
| 199 | +); |
| 200 | +expect(bridgeChild).toBe(child); |
| 201 | +expect(bridgeOptions).toEqual(expect.objectContaining({ onSignal: expect.any(Function) })); |
191 | 202 | |
192 | 203 | child.emit("exit", 0, null); |
193 | 204 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。