Skip to content

Commit a2228bc

Browse files
authored
test(api): strengthen validation tests for speed and scale query params (JhaSourav07#173)
## Description Fixes JhaSourav07#158 Added additional validation test coverage for invalid speed and scale query parameter values. Included tests for: - speed=10 - scale=foo Also verified fallback/default behavior continues to work correctly for invalid inputs. ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview ## 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 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). - [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents a030930 + d688f11 commit a2228bc

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

app/api/streak/route.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ describe('GET /api/streak', () => {
195195
// "5" doesn't match /^\d+(\.\d+)?s$/, so the default kicks in.
196196
expect(body).toContain('8s');
197197
});
198+
199+
it('falls back to 8s when speed=10 is provided', async () => {
200+
const response = await GET(makeRequest({ user: 'octocat', speed: '10' }));
201+
const body = await response.text();
202+
203+
expect(body).toContain('8s');
204+
});
198205
});
199206

200207
describe('scale parameter', () => {
@@ -211,6 +218,12 @@ describe('GET /api/streak', () => {
211218

212219
expect(response.status).toBe(200);
213220
});
221+
222+
it('defaults to linear scale when scale=foo is given', async () => {
223+
const response = await GET(makeRequest({ user: 'octocat', scale: 'foo' }));
224+
225+
expect(response.status).toBe(200);
226+
});
214227
});
215228

216229
describe('theme parameter', () => {

0 commit comments

Comments
 (0)