Skip to content

Commit 3907f7e

Browse files
committed
test(cache): verify Date instance values
1 parent 4fc855a commit 3907f7e

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

lib/cache.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,20 @@ describe('TTLCache', () => {
402402
expect(cache.get('tags')).toEqual(tags);
403403
cache.destroy();
404404
});
405+
it('preserves Date instance values in TTLCache', () => {
406+
const cache = new TTLCache<Date>();
407+
408+
const date = new Date('2026-05-31T00:00:00.000Z');
409+
410+
cache.set('created-at', date, 60_000);
411+
412+
const cached = cache.get('created-at');
413+
414+
expect(cached).toBeInstanceOf(Date);
415+
expect(cached?.toISOString()).toBe(date.toISOString());
416+
417+
cache.destroy();
418+
});
405419

406420
it('stores and retrieves nested object values', () => {
407421
const cache = new TTLCache<{

0 commit comments

Comments
 (0)