MCPcopy
hub / github.com/callumalpass/tasknotes / FakeTimer

Class FakeTimer

tests/unit/bootstrap/dateChangeDetection.test.ts:6–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4} from "../../../src/bootstrap/dateChangeDetection";
5
6class FakeTimer {
7 private nextId = 1;
8 intervals: Array<{ id: number; callback: () => void; timeout: number }> = [];
9 timeouts: Array<{ id: number; callback: () => void; timeout: number }> = [];
10 clearedTimeouts: number[] = [];
11
12 setInterval(callback: () => void, timeout: number): number {
13 const id = this.nextId++;
14 this.intervals.push({ id, callback, timeout });
15 return id;
16 }
17
18 setTimeout(callback: () => void, timeout: number): number {
19 const id = this.nextId++;
20 this.timeouts.push({ id, callback, timeout });
21 return id;
22 }
23
24 clearTimeout(timeoutId: number): void {
25 this.clearedTimeouts.push(timeoutId);
26 }
27}
28
29describe("date change detection", () => {
30 it("registers a minute interval and schedules the next local midnight", () => {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected