test: dedupe cron scope mock reads · openclaw/openclaw@1ade7a5
steipete
·
2026-05-13
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -30,6 +30,12 @@ import "./test-helpers/fast-bash-tools.js";
|
30 | 30 | import "./test-helpers/fast-coding-tools.js"; |
31 | 31 | import { createOpenClawCodingTools } from "./pi-tools.js"; |
32 | 32 | |
| 33 | +function firstOpenClawToolsOptions(): { cronSelfRemoveOnlyJobId?: string } | undefined { |
| 34 | +return mocks.createOpenClawToolsOptions.mock.calls[0]?.[0] as |
| 35 | +| { cronSelfRemoveOnlyJobId?: string } |
| 36 | +| undefined; |
| 37 | +} |
| 38 | + |
33 | 39 | describe("createOpenClawCodingTools cron scope", () => { |
34 | 40 | beforeEach(() => { |
35 | 41 | mocks.createOpenClawToolsOptions.mockClear(); |
@@ -44,8 +50,7 @@ describe("createOpenClawCodingTools cron scope", () => {
|
44 | 50 | }); |
45 | 51 | |
46 | 52 | expect(tools.map((tool) => tool.name)).toContain("cron"); |
47 | | -const [options] = mocks.createOpenClawToolsOptions.mock.calls.at(0) ?? []; |
48 | | -expect(options?.cronSelfRemoveOnlyJobId).toBe("job-current"); |
| 53 | +expect(firstOpenClawToolsOptions()?.cronSelfRemoveOnlyJobId).toBe("job-current"); |
49 | 54 | }); |
50 | 55 | |
51 | 56 | it("does not scope ordinary owner cron sessions", () => { |
@@ -55,7 +60,6 @@ describe("createOpenClawCodingTools cron scope", () => {
|
55 | 60 | senderIsOwner: true, |
56 | 61 | }); |
57 | 62 | |
58 | | -const [options] = mocks.createOpenClawToolsOptions.mock.calls.at(0) ?? []; |
59 | | -expect(options?.cronSelfRemoveOnlyJobId).toBeUndefined(); |
| 63 | +expect(firstOpenClawToolsOptions()?.cronSelfRemoveOnlyJobId).toBeUndefined(); |
60 | 64 | }); |
61 | 65 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。