Skip to content

Commit a54669c

Browse files
authored
test(cache): verify Date instance values (JhaSourav07#1926)
## Description Fixes JhaSourav07#1407 Added a TTLCache test to verify that Date instance values are preserved correctly when stored and retrieved from the cache. ## Pillar * [ ] 🎨 Pillar 1 — New Theme Design * [ ] 📐 Pillar 2 — Geometric SVG Improvement * [ ] 🕐 Pillar 3 — Timezone Logic Optimization * [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview Not applicable — test-only change. ## Checklist before requesting a review: * [x] I have read the `CONTRIBUTING.md` file. * [ ] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). * [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). * [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). * [ ] I have updated `README.md` if I added a new theme or URL parameter. * [x] I have started the repo. * [x] I have made sure that I have only one commit to merge in this PR. * [ ] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). * [ ] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents a6b5fda + 3907f7e commit a54669c

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)