import { describe, expect, it } from "vitest"; import { waitUntil } from "../src/lib/idle.js"; describe("waitUntil", () => { it("resolves true when the predicate is already true", async () => { expect(await waitUntil(() => true, { timeoutMs: 100 })).toBe(true); }); it("waits until the predicate flips", async () => { let ready = false; setTimeout(() => { ready = true; }, 30); expect(await waitUntil(() => ready, { timeoutMs: 500, intervalMs: 10 })).toBe(true); }); it("returns false on timeout", async () => { expect(await waitUntil(() => false, { timeoutMs: 40, intervalMs: 10 })).toBe(false); }); });