mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 19:24:46 +00:00
test: dedupe cron scope mock reads
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user