A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
test(cache): freeze clock for ttl resolution (#3415)
Hampusf8d85f0e5e3f
diff --git a/fluxer_api/pkgs/cache/src/__tests__/CacheGetOrSet.test.ts b/fluxer_api/pkgs/cache/src/__tests__/CacheGetOrSet.test.tsindex 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);