From 10d30e6b094c1c9651a7eb9747b7790d7f75a2a8 Mon Sep 17 00:00:00 2001 From: Jared Wray Date: Fri, 19 Jan 2024 16:13:13 -0600 Subject: [PATCH] fixing multi-cache testing of ttl wrap function (#636) * fixing multi-cache testing of ttl wrap function * updating sleep --- test/caching.test.ts | 2 +- test/multi-caching.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/caching.test.ts b/test/caching.test.ts index 1fed1a0b..fd682b6b 100644 --- a/test/caching.test.ts +++ b/test/caching.test.ts @@ -241,7 +241,7 @@ describe('caching', () => { await expect(cache.wrap(key, async () => 'foo')).resolves.toEqual(value); expect(fn).toHaveBeenCalledTimes(1); - await sleep(2000); + await sleep(3000); await expect(cache.get(key)).resolves.toBeUndefined(); }); diff --git a/test/multi-caching.test.ts b/test/multi-caching.test.ts index f7c87052..4f403e37 100644 --- a/test/multi-caching.test.ts +++ b/test/multi-caching.test.ts @@ -111,7 +111,7 @@ describe('multiCaching', () => { // eslint-disable-next-line @typescript-eslint/no-unused-vars const sec = faker.number.int({ min: 2, max: 4 }); value = faker.string.sample(sec * 2); - const fn = vi.fn((v: string) => (v.length / 2) * 1000); + const fn = vi.fn((v: string) => 1000); await multiCache.wrap(key, async () => value, fn); await expect(memoryCache.get(key)).resolves.toEqual(value); await expect(memoryCache2.get(key)).resolves.toEqual(value); @@ -120,7 +120,7 @@ describe('multiCaching', () => { value, ); expect(fn).toHaveBeenCalledTimes(1); - await sleep(sec * 1000); + await sleep(3000); await expect(memoryCache.get(key)).resolves.toBeUndefined(); await expect(memoryCache2.get(key)).resolves.toBeUndefined(); await expect(memoryCache3.get(key)).resolves.toBeUndefined();