Skip to content

Commit 9eee012

Browse files
committed
test(cache): verify near-zero positive TTL values do not throw
1 parent 7538218 commit 9eee012

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

lib/cache.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,25 @@ describe('TTLCache', () => {
381381
expect([null, 'lived']).toContain(result);
382382
cache.destroy();
383383
});
384+
it('does not throw when ttlMs is Number.EPSILON', () => {
385+
const cache = new TTLCache<string>();
386+
387+
expect(() => {
388+
cache.set('key', 'value', Number.EPSILON);
389+
}).not.toThrow();
390+
391+
cache.destroy();
392+
});
393+
394+
it('does not throw when ttlMs is a very small positive number', () => {
395+
const cache = new TTLCache<string>();
396+
397+
expect(() => {
398+
cache.set('key', 'value', 0.0001);
399+
}).not.toThrow();
400+
401+
cache.destroy();
402+
});
384403

385404
it('multiple clear operations work correctly', () => {
386405
const cache = new TTLCache<string>();

0 commit comments

Comments
 (0)