Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,23 @@ describe('TTLCache', () => {

cache.destroy();
});
// FIX: New test targeting the NaN boundary for Issue #1399
it('resolves NaN TTL to the default standard TTL duration', () => {
vi.useFakeTimers();
const cache = new TTLCache<string>();

// Setting with NaN should not throw; it should fallback to the default TTL
expect(() => cache.set('nan-key', 'value', NaN)).not.toThrow();

// The item should be successfully stored
expect(cache.get('nan-key')).toBe('value');

// Advance by a small amount to ensure it didn't instantly expire
vi.advanceTimersByTime(1000);
expect(cache.get('nan-key')).toBe('value');

cache.destroy();
});

it('verify TTLCache behavior for infinite TTL value (Variation 1)', () => {
const cache = new TTLCache<string>();
Expand Down
Loading