mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-19 09:01:39 -06:00
3d76246792
* refactor: resolve final export name collisions * refactor: update remaining collision rename consumers * style: format rebased auth helpers * test: update remaining session entry mocks * test: update remaining runtime mock exports * test: update delivery info path mock * refactor: reconcile combined collision sweeps * chore: regenerate collision and sdk baselines
24 lines
811 B
TypeScript
24 lines
811 B
TypeScript
/** Tests node-host timeout handling, abort reasons, and cleanup behavior. */
|
|
import { MAX_TIMER_TIMEOUT_MS } from "@openclaw/normalization-core/number-coercion";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { runAbortableTimeout } from "./with-timeout.js";
|
|
|
|
describe("runAbortableTimeout", () => {
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
it("caps huge finite timeoutMs before scheduling the timer", async () => {
|
|
const setTimeoutSpy = vi.spyOn(globalThis, "setTimeout");
|
|
|
|
await expect(
|
|
runAbortableTimeout(async (signal) => {
|
|
expect(signal?.aborted).toBe(false);
|
|
return "ok";
|
|
}, Number.MAX_SAFE_INTEGER),
|
|
).resolves.toBe("ok");
|
|
|
|
expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS);
|
|
});
|
|
});
|