diff --git a/__tests__/kv/index.test.ts b/__tests__/kv/index.test.ts index c6cad90..9e23ca7 100644 --- a/__tests__/kv/index.test.ts +++ b/__tests__/kv/index.test.ts @@ -20,7 +20,7 @@ describe('KV', () => { expect(json).toEqual({ key: 'value' }); }); it('can cache', async () => { - const manager = KVManager.for('test', 2 * 1000); + const manager = KVManager.for('test', 500); const spy = jest.spyOn(manager.kv, 'get'); @@ -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' });