Skip to content

Commit b7cebef

Browse files
authored
test(validations): verify view parameter behavior (JhaSourav07#1163)
## Description Fixes JhaSourav07#1041 Added validation tests for the `view` parameter in `streakParamsSchema`. The tests verify that: * `view: "default"` is accepted * `view: "monthly"` is accepted * invalid values (e.g. `"radar"`) fall back to `"default"` * omitted `view` defaults to `"default"` ## Pillar * [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview N/A (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 (not applicable — test-only change). * [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents b2ab7ef + 58c4338 commit b7cebef

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

lib/validations.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,3 +432,21 @@ describe('ogParamsSchema', () => {
432432
expect(result.user).toBe('unknown');
433433
});
434434
});
435+
436+
describe('streakParamsSchema — view fallback behavior', () => {
437+
it('accepts "default" as a valid view value', () => {
438+
expect(parse({ view: 'default' }).view).toBe('default');
439+
});
440+
441+
it('accepts "monthly" as a valid view value', () => {
442+
expect(parse({ view: 'monthly' }).view).toBe('monthly');
443+
});
444+
445+
it('falls back to "default" for unknown view value', () => {
446+
expect(parse({ view: 'radar' }).view).toBe('default');
447+
});
448+
449+
it('defaults to "default" when view is omitted', () => {
450+
expect(parse({}).view).toBe('default');
451+
});
452+
});

0 commit comments

Comments
 (0)