test(cache): freeze clock for ttl resolution (#3415)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-12 13:37:56 +02:00
1 parent 7f674474b5
commit f8d85f0e5e
1 file changed
+3 -1
+3 -1
View File
@@ -62,7 +62,9 @@ describe('ICacheService.getOrSet', () => {
expect(factory).toHaveBeenCalledTimes(1); 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 client = new MockKVProvider();
const provider = new KVCacheProvider({client}); const provider = new KVCacheProvider({client});
const resolver = (value: number | null) => (value === null ? 5 : 30); const resolver = (value: number | null) => (value === null ? 5 : 30);