Skip to content

Commit bd32bd5

Browse files
authored
test(route): verify invalid view falls back to default (JhaSourav07#1197)
## Description Fixes JhaSourav07#1037 Added a route-level test to verify that an invalid `view` parameter falls back to the default isometric view. ### Test Coverage Added * Sends a request with `?user=octocat&view=invalid` * Verifies the response status is `200` * Verifies the generated SVG contains `@keyframes grow-up` * Confirms unknown view values render the default isometric monolith view ## 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. * [x] 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 starred 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 (no raw elements, smooth animations, correct fonts). * [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 617839c + 67a522c commit bd32bd5

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

app/api/streak/route.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ describe('GET /api/streak', () => {
8787
vi.mocked(getSecondsUntilMidnightInTimezone).mockReturnValue(7200);
8888
});
8989

90+
it('falls back to the default isometric view when an invalid view is provided', async () => {
91+
const request = new Request('http://localhost:3000/api/streak?user=octocat&view=invalid');
92+
93+
const response = await GET(request);
94+
95+
expect(response.status).toBe(200);
96+
97+
const body = await response.text();
98+
99+
expect(body).toContain('@keyframes grow-up');
100+
});
101+
90102
describe('parameter validation', () => {
91103
it('returns 400 when the user parameter is missing', async () => {
92104
const response = await GET(makeRequest());

0 commit comments

Comments
 (0)