From f8d85f0e5e3f4b1dac306cbf5de7ab318f378bae Mon Sep 17 00:00:00 2001 From: Hampus Date: Mon, 12 Oct 2026 13:37:56 +0200 Subject: [PATCH] test(cache): freeze clock for ttl resolution (#3415) --- fluxer_api/pkgs/cache/src/__tests__/CacheGetOrSet.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fluxer_api/pkgs/cache/src/__tests__/CacheGetOrSet.test.ts b/fluxer_api/pkgs/cache/src/__tests__/CacheGetOrSet.test.ts index bbc3f555e..cc6ff1eff 100644 --- a/fluxer_api/pkgs/cache/src/__tests__/CacheGetOrSet.test.ts +++ b/fluxer_api/pkgs/cache/src/__tests__/CacheGetOrSet.test.ts @@ -62,7 +62,9 @@ describe('ICacheService.getOrSet', () => { expect(factory).toHaveBeenCalledTimes(1); }); - it('resolves the ttl from the produced value', async () => { + it('resolves the ttl from the produced value', async ({onTestFinished}) => { + const now = vi.spyOn(Date, 'now').mockReturnValue(1_000); + onTestFinished(() => now.mockRestore()); const client = new MockKVProvider(); const provider = new KVCacheProvider({client}); const resolver = (value: number | null) => (value === null ? 5 : 30);