Skip to content

Commit c46c68b

Browse files
committed
🚨 Add tests for cache (#1995)
1 parent 566633d commit c46c68b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/test/lib/clients/cache.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe('Cache', () => {
1919
});
2020

2121
test('expects to throw error if TTL is not positive', () => {
22+
expect(() => new Cache<string>(0)).toThrow('TTL must be positive');
2223
expect(() => new Cache<string>(-1)).toThrow('TTL must be positive');
2324
expect(() => new Cache<string>(-2)).toThrow('TTL must be positive');
2425
});
@@ -202,6 +203,12 @@ describe('Cache', () => {
202203
expect(health.size).toBe(2);
203204
expect(health.oldestEntry).toBe(new Date('2023-01-01T00:00:00.000Z').getTime());
204205
});
206+
207+
test('expects to handle empty cache health information', () => {
208+
const cache = new Cache<string>();
209+
const health = cache.health;
210+
expect(health.size).toBe(0);
211+
});
205212
});
206213

207214
describe('delete and clear', () => {

0 commit comments

Comments
 (0)