diff --git a/package-lock.json b/package-lock.json index 313a5cd..2dd0474 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6338,9 +6338,9 @@ } }, "node_modules/ws": { - "version": "8.18.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", - "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", + "version": "8.21.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.1.tgz", + "integrity": "sha512-+0NTnW77fFN/DjQi6k/Sq/Yvk4Sgajw7urW8V+asjXnRgDs9gyGkdb7EzgfhA4goXsRIZKE28fzIXBHEzhuiWw==", "dev": true, "license": "MIT", "engines": { diff --git a/tests/gemini.test.js b/tests/gemini.test.js index 3acca2f..9f8536f 100644 --- a/tests/gemini.test.js +++ b/tests/gemini.test.js @@ -1500,21 +1500,28 @@ describe("Gemini Component", () => { }); test("should handle clearExpiredSummary with exactly 24 hours", async () => { - const exactTimestamp = Date.now() - 86400 * 1000; + const now = Date.now(); + const dateNowSpy = jest.spyOn(Date, "now").mockReturnValue(now); - mockChromeStorage({ - summaryList: [{ name: "Place", clue: "" }], - timestamp: exactTimestamp, - favoriteList: [], - }); + try { + const exactTimestamp = now - 86400 * 1000; - geminiInstance.clearExpiredSummary(); + mockChromeStorage({ + summaryList: [{ name: "Place", clue: "" }], + timestamp: exactTimestamp, + favoriteList: [], + }); + + geminiInstance.clearExpiredSummary(); - // Wait for the async storage callback to complete - await flushPromises(); + // Wait for the async storage callback to complete + await flushPromises(); - // Should not clear (exactly 24 hours is still valid - elapsedTime > 86400 is false) - expect(state.hasSummary).toBe(true); + // Should not clear (exactly 24 hours is still valid - elapsedTime > 86400 is false) + expect(state.hasSummary).toBe(true); + } finally { + dateNowSpy.mockRestore(); + } }); test("should handle video summary requests", async () => {