Skip to content

Commit

Permalink
test: fix testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed Jun 21, 2024
1 parent 341a7cf commit 87d7f77
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions __tests__/kv/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('KV', () => {
expect(json).toEqual({ key: 'value' });
});
it('can cache', async () => {
const manager = KVManager.for<any>('test', 2 * 1000);
const manager = KVManager.for<any>('test', 500);

const spy = jest.spyOn(manager.kv, 'get');

Expand All @@ -34,8 +34,9 @@ describe('KV', () => {
const b = await manager.getJSONCached('key');
expect(b).toEqual({ key: 'value' });

// should only call once, the second time should get from cache
expect(spy).toBeCalledTimes(1);
await sleep(2000);
await sleep(4000);

const c = await manager.getJSONCached('key');
expect(c).toEqual({ key: 'value' });
Expand Down

0 comments on commit 87d7f77

Please sign in to comment.