Skip to content

Commit 0f06a12

Browse files
authored
test(utils): check date range formatter boundary robustness (JhaSourav07#1564) (JhaSourav07#1667)
## Description Fixes JhaSourav07#1564 Added a boundary robustness test for year-based date range generation in the streak API route. The new test verifies that when `?year=2008` is provided, the utility generates the correct lower-bound date range and passes the expected `from` and `to` values to contribution fetching logic. ## Pillar * [ ] 🎨 Pillar 1 — New Theme Design * [ ] 📐 Pillar 2 — Geometric SVG Improvement * [ ] 🕐 Pillar 3 — Timezone Logic Optimization * [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview N/A (test-only changes) ## Checklist before requesting a review: * [x] I have read the `CONTRIBUTING.md` file. * [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). * [ ] 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. * [ ] 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 (not applicable for test-only changes). * [ ] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support. ## Test Validation Command executed: ```bash npx vitest run app/api/streak/route.test.ts ``` Result: ```text ✓ app/api/streak/route.test.ts Test Files 1 passed (1) Tests 114 passed (114) ``` ## Files Changed * app/api/streak/route.test.ts ## Notes * Added one new boundary-focused test block. * Verified correct `from` and `to` date range generation for the lower-bound year case (`2008`). * No production code changes were made.
2 parents 889f3a2 + 6be4353 commit 0f06a12

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

app/api/streak/route.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,16 @@ describe('GET /api/streak', () => {
437437
});
438438
});
439439

440+
it('passes correct from/to range when ?year=2008 is provided', async () => {
441+
await GET(makeRequest({ user: 'octocat', year: '2008' }));
442+
443+
expect(fetchGitHubContributions).toHaveBeenCalledWith('octocat', {
444+
bypassCache: false,
445+
from: '2008-01-01T00:00:00Z',
446+
to: '2008-12-31T23:59:59Z',
447+
});
448+
});
449+
440450
it('functions normally when the year parameter is missing', async () => {
441451
const response = await GET(makeRequest({ user: 'octocat' }));
442452

0 commit comments

Comments
 (0)