Skip to content

Commit 18f5bd3

Browse files
authored
test(svg): add year parameter route test (JhaSourav07#613)
## Description Fixes JhaSourav07#365 Added a test case to verify that the `?year=` parameter correctly passes the expected `from` and `to` date range values to `fetchGitHubContributions`. ## Changes made * Added route test for `?year=2023` * Asserted correct date range: * `from: '2023-01-01T00:00:00Z'` * `to: '2023-12-31T23:59:59Z'` ## 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. - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors. - [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. - [x] The SVG output matches the CommitPulse "premium quality" aesthetic standard. - [x] I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents cf595db + 4003c2e commit 18f5bd3

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
@@ -249,6 +249,16 @@ describe('GET /api/streak', () => {
249249
expect(response.status).toBe(200);
250250
});
251251

252+
it('passes correct from/to range when ?year=2023 is provided', async () => {
253+
await GET(makeRequest({ user: 'octocat', year: '2023' }));
254+
255+
expect(fetchGitHubContributions).toHaveBeenCalledWith('octocat', {
256+
bypassCache: false,
257+
from: '2023-01-01T00:00:00Z',
258+
to: '2023-12-31T23:59:59Z',
259+
});
260+
});
261+
252262
it('functions normally when the year parameter is missing', async () => {
253263
const response = await GET(makeRequest({ user: 'octocat' }));
254264

0 commit comments

Comments
 (0)