test: dedupe cron scope mock reads

This commit is contained in:
Peter Steinberger
2026-05-13 00:43:49 +01:00
parent f2935ca3ec
commit 1ade7a53af

View File

@@ -30,6 +30,12 @@ import "./test-helpers/fast-bash-tools.js";
import "./test-helpers/fast-coding-tools.js";
import { createOpenClawCodingTools } from "./pi-tools.js";
function firstOpenClawToolsOptions(): { cronSelfRemoveOnlyJobId?: string } | undefined {
return mocks.createOpenClawToolsOptions.mock.calls[0]?.[0] as
| { cronSelfRemoveOnlyJobId?: string }
| undefined;
}
describe("createOpenClawCodingTools cron scope", () => {
beforeEach(() => {
mocks.createOpenClawToolsOptions.mockClear();
@@ -44,8 +50,7 @@ describe("createOpenClawCodingTools cron scope", () => {
});
expect(tools.map((tool) => tool.name)).toContain("cron");
const [options] = mocks.createOpenClawToolsOptions.mock.calls.at(0) ?? [];
expect(options?.cronSelfRemoveOnlyJobId).toBe("job-current");
expect(firstOpenClawToolsOptions()?.cronSelfRemoveOnlyJobId).toBe("job-current");
});
it("does not scope ordinary owner cron sessions", () => {
@@ -55,7 +60,6 @@ describe("createOpenClawCodingTools cron scope", () => {
senderIsOwner: true,
});
const [options] = mocks.createOpenClawToolsOptions.mock.calls.at(0) ?? [];
expect(options?.cronSelfRemoveOnlyJobId).toBeUndefined();
expect(firstOpenClawToolsOptions()?.cronSelfRemoveOnlyJobId).toBeUndefined();
});
});