mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 00:52:53 +00:00
19 lines
729 B
TypeScript
19 lines
729 B
TypeScript
import { MAX_TIMER_TIMEOUT_MS } from "openclaw/plugin-sdk/number-runtime";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { withTimeout } from "./sdk-node-runtime.js";
|
|
|
|
describe("withTimeout", () => {
|
|
it("caps oversized timeouts before arming the abort timer", async () => {
|
|
const timeoutSpy = vi
|
|
.spyOn(globalThis, "setTimeout")
|
|
.mockReturnValue(1 as unknown as ReturnType<typeof setTimeout>);
|
|
vi.spyOn(globalThis, "clearTimeout").mockImplementation(() => undefined);
|
|
|
|
await expect(
|
|
withTimeout(async () => "ok", Number.MAX_SAFE_INTEGER, "browser request"),
|
|
).resolves.toBe("ok");
|
|
|
|
expect(timeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS);
|
|
});
|
|
});
|