File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff 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+
181202describe ( "DashboardPage — data flow" , ( ) => {
182203 it ( "passes fetched issues to IssuesTab" , async ( ) => {
183204 const issues = [
You can’t perform that action at this time.
0 commit comments