Skip to content

Commit d6e4432

Browse files
committed
test(cache): verify TTLCache throws RangeError for negative TTL (JhaSourav07#1398)
1 parent 292db5e commit d6e4432

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/cache.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,13 @@ describe('TTLCache', () => {
363363
});
364364

365365
describe('edge cases and error handling', () => {
366+
// FIX: New test explicitly targeting the -5000 boundary for Issue #1398
367+
it('throws RangeError when setting a value with -5000 TTL', () => {
368+
const cache = new TTLCache<string>();
369+
expect(() => cache.set('key', 'value', -5000)).toThrow(RangeError);
370+
cache.destroy();
371+
});
372+
366373
it('throws RangeError when ttlMs is 0 or negative', () => {
367374
const cache = new TTLCache<string>();
368375
expect(() => cache.set('key', 'value', 0)).toThrow(RangeError);
@@ -401,6 +408,7 @@ describe('TTLCache', () => {
401408
expect([null, 'lived']).toContain(result);
402409
cache.destroy();
403410
});
411+
404412
it('does not throw when ttlMs is Number.EPSILON', () => {
405413
const cache = new TTLCache<string>();
406414

0 commit comments

Comments
 (0)