Skip to content

Commit 1ade7a5

Browse files
committed
test: dedupe cron scope mock reads
1 parent f2935ca commit 1ade7a5

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/agents/pi-tools.cron-scope.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ import "./test-helpers/fast-bash-tools.js";
3030
import "./test-helpers/fast-coding-tools.js";
3131
import { createOpenClawCodingTools } from "./pi-tools.js";
3232

33+
function firstOpenClawToolsOptions(): { cronSelfRemoveOnlyJobId?: string } | undefined {
34+
return mocks.createOpenClawToolsOptions.mock.calls[0]?.[0] as
35+
| { cronSelfRemoveOnlyJobId?: string }
36+
| undefined;
37+
}
38+
3339
describe("createOpenClawCodingTools cron scope", () => {
3440
beforeEach(() => {
3541
mocks.createOpenClawToolsOptions.mockClear();
@@ -44,8 +50,7 @@ describe("createOpenClawCodingTools cron scope", () => {
4450
});
4551

4652
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");
4954
});
5055

5156
it("does not scope ordinary owner cron sessions", () => {
@@ -55,7 +60,6 @@ describe("createOpenClawCodingTools cron scope", () => {
5560
senderIsOwner: true,
5661
});
5762

58-
const [options] = mocks.createOpenClawToolsOptions.mock.calls.at(0) ?? [];
59-
expect(options?.cronSelfRemoveOnlyJobId).toBeUndefined();
63+
expect(firstOpenClawToolsOptions()?.cronSelfRemoveOnlyJobId).toBeUndefined();
6064
});
6165
});

0 commit comments

Comments
 (0)