UNPKG

wundertec-core

Version:

Librería estándar de utilidades e integraciones AWS + helpers generales

21 lines (17 loc) 561 B
import { withTimeout } from "../../src/utils/timeout"; describe("withTimeout()", () => { jest.useFakeTimers(); it("resolves if promise completes within time", async () => { const promise = withTimeout(Promise.resolve("ok"), 500); await expect(promise).resolves.toBe("ok"); }); it("rejects with provided error on timeout", async () => { const promise = withTimeout( new Promise(() => {}), 500, new Error("timeout") ); jest.advanceTimersByTime(500); await expect(promise).rejects.toThrow("timeout"); }); });