Files
openclaw/extensions/browser/src/sdk-node-runtime.test.ts
2026-06-04 21:40:44 -04:00

20 lines
786 B
TypeScript

// Browser tests cover sdk node runtime plugin behavior.
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);
});
});