mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
test(cache): freeze clock for ttl resolution (#3415)
This commit is contained in:
1 parent
7f674474b5
commit
f8d85f0e5e
1 file changed
+3
-1
@@ -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);
|
||||||
|
|||||||
Reference in new issue
Block a user