test: dedupe heartbeat override mock reads · openclaw/openclaw@9531bef
steipete
·
2026-05-13
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -32,6 +32,10 @@ function expectReplyOptions(options: unknown, expected: Record<string, unknown>)
|
32 | 32 | return actual; |
33 | 33 | } |
34 | 34 | |
| 35 | +function firstReplyCall(replySpy: HeartbeatReplySpy) { |
| 36 | +return replySpy.mock.calls[0] ?? []; |
| 37 | +} |
| 38 | + |
35 | 39 | async function withHeartbeatFixture( |
36 | 40 | run: (ctx: { |
37 | 41 | tmpDir: string; |
@@ -83,9 +87,10 @@ describe("runHeartbeatOnce – heartbeat model override", () => {
|
83 | 87 | }); |
84 | 88 | |
85 | 89 | expect(params.replySpy).toHaveBeenCalledTimes(1); |
| 90 | +const [ctx, opts] = firstReplyCall(params.replySpy); |
86 | 91 | return { |
87 | | -ctx: params.replySpy.mock.calls.at(0)?.[0], |
88 | | -opts: params.replySpy.mock.calls.at(0)?.[1], |
| 92 | + ctx, |
| 93 | + opts, |
89 | 94 | replySpy: params.replySpy, |
90 | 95 | }; |
91 | 96 | } |
@@ -167,7 +172,7 @@ describe("runHeartbeatOnce – heartbeat model override", () => {
|
167 | 172 | }); |
168 | 173 | |
169 | 174 | expect(result.replySpy).toHaveBeenCalledTimes(1); |
170 | | -const [ctx, opts, passedConfig] = result.replySpy.mock.calls.at(0) ?? []; |
| 175 | +const [ctx, opts, passedConfig] = firstReplyCall(result.replySpy); |
171 | 176 | if (!ctx || typeof ctx !== "object") { |
172 | 177 | throw new Error("expected heartbeat reply context"); |
173 | 178 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。