Skip to content

Commit 04255f5

Browse files
committed
test: adds clock tick interval and cleanup assertions
1 parent 02cea2d commit 04255f5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/components/DashboardPage.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,27 @@ describe("DashboardPage — tab switching", () => {
178178
});
179179
});
180180

181+
describe("DashboardPage — clock tick", () => {
182+
it("creates a 60s interval to keep relative time displays fresh", () => {
183+
const spy = vi.spyOn(globalThis, "setInterval");
184+
render(() => <DashboardPage />);
185+
expect(spy.mock.calls.some(([, ms]) => ms === 60_000)).toBe(true);
186+
spy.mockRestore();
187+
});
188+
189+
it("clears the interval on unmount", () => {
190+
const setSpy = vi.spyOn(globalThis, "setInterval");
191+
const clearSpy = vi.spyOn(globalThis, "clearInterval");
192+
const { unmount } = render(() => <DashboardPage />);
193+
const clockCall = setSpy.mock.calls.find(([, ms]) => ms === 60_000);
194+
expect(clockCall).toBeDefined();
195+
unmount();
196+
expect(clearSpy).toHaveBeenCalled();
197+
setSpy.mockRestore();
198+
clearSpy.mockRestore();
199+
});
200+
});
201+
181202
describe("DashboardPage — data flow", () => {
182203
it("passes fetched issues to IssuesTab", async () => {
183204
const issues = [

0 commit comments

Comments
 (0)