Files
openclaw/src/utils/timer-delay.test.ts
2026-05-30 06:27:13 +01:00

16 lines
525 B
TypeScript

import { describe, expect, it, vi } from "vitest";
import { MAX_SAFE_TIMEOUT_DELAY_MS, setSafeTimeout } from "./timer-delay.js";
describe("setSafeTimeout", () => {
it("arms setTimeout with the clamped delay", () => {
const timeoutSpy = vi.spyOn(globalThis, "setTimeout");
const callback = () => undefined;
const timer = setSafeTimeout(callback, 3_000_000_000);
clearTimeout(timer);
expect(timeoutSpy).toHaveBeenCalledWith(callback, MAX_SAFE_TIMEOUT_DELAY_MS);
timeoutSpy.mockRestore();
});
});