@@ -1500,21 +1500,28 @@ describe("Gemini Component", () => {
15001500 } ) ;
15011501
15021502 test ( "should handle clearExpiredSummary with exactly 24 hours" , async ( ) => {
1503- const exactTimestamp = Date . now ( ) - 86400 * 1000 ;
1503+ const now = Date . now ( ) ;
1504+ const dateNowSpy = jest . spyOn ( Date , "now" ) . mockReturnValue ( now ) ;
15041505
1505- mockChromeStorage ( {
1506- summaryList : [ { name : "Place" , clue : "" } ] ,
1507- timestamp : exactTimestamp ,
1508- favoriteList : [ ] ,
1509- } ) ;
1506+ try {
1507+ const exactTimestamp = now - 86400 * 1000 ;
15101508
1511- geminiInstance . clearExpiredSummary ( ) ;
1509+ mockChromeStorage ( {
1510+ summaryList : [ { name : "Place" , clue : "" } ] ,
1511+ timestamp : exactTimestamp ,
1512+ favoriteList : [ ] ,
1513+ } ) ;
1514+
1515+ geminiInstance . clearExpiredSummary ( ) ;
15121516
1513- // Wait for the async storage callback to complete
1514- await flushPromises ( ) ;
1517+ // Wait for the async storage callback to complete
1518+ await flushPromises ( ) ;
15151519
1516- // Should not clear (exactly 24 hours is still valid - elapsedTime > 86400 is false)
1517- expect ( state . hasSummary ) . toBe ( true ) ;
1520+ // Should not clear (exactly 24 hours is still valid - elapsedTime > 86400 is false)
1521+ expect ( state . hasSummary ) . toBe ( true ) ;
1522+ } finally {
1523+ dateNowSpy . mockRestore ( ) ;
1524+ }
15181525 } ) ;
15191526
15201527 test ( "should handle video summary requests" , async ( ) => {
0 commit comments