mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-30 21:23:35 +00:00
17 lines
599 B
TypeScript
17 lines
599 B
TypeScript
// Timer delay tests cover safe timeout clamping and scheduling behavior.
|
|
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();
|
|
});
|
|
});
|