Skip to content

Commit

Permalink
fixing multi-cache testing of ttl wrap function (#636)
Browse files Browse the repository at this point in the history
* fixing multi-cache testing of ttl wrap function

* updating sleep
  • Loading branch information
jaredwray authored Jan 19, 2024
1 parent 2f6d831 commit 10d30e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/caching.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
4 changes: 2 additions & 2 deletions test/multi-caching.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit 10d30e6

Please sign in to comment.