@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
tsx 32 lines 1.1 KB
Raw
1 import { act, useLayoutEffect } from "react";
2 import { createRoot } from "react-dom/client";
3 import { expect, it, vi } from "vite-plus/test";
4
5 import { useThreadListNow } from "./use-thread-list-now";
6
7 const MINUTE_MS = Date.UTC(2026, 9, 27, 12, 0);
8 const iso = (secondsIntoMinute: number) =>
9 new Date(MINUTE_MS + secondsIntoMinute * 1000).toISOString();
10
11 it("wakes for each snooze that expires within the same minute", async () => {
12 using _timers = { [Symbol.dispose]: () => vi.useRealTimers() };
13 vi.useFakeTimers({ now: MINUTE_MS + 10_000 });
14 const threads = [{ snoozedUntil: iso(30) }, { snoozedUntil: iso(40) }];
15 const seen: string[] = [];
16 function Probe() {
17 const now = useThreadListNow(threads);
18 useLayoutEffect(() => {
19 seen.push(now);
20 });
21 return null;
22 }
23
24 const root = createRoot(document.createElement("div"));
25 await act(async () => root.render(<Probe />));
26 await act(async () => vi.advanceTimersByTime(20_000));
27 expect(seen.at(-1)).toBe(iso(30));
28
29 await act(async () => vi.advanceTimersByTime(10_000));
30 expect(seen.at(-1)).toBe(iso(40));
31 act(() => root.unmount());
32 });