Skip to content

Commit b6fe25d

Browse files
authored
test(streak): Adds text colour parameter route tests (JhaSourav07#600)
## Description Adds two missing test cases for the '?text=' query parameter in the streak route: ->Asserts that '?text=ff0000' causes the hex '#ff0000' to appear in the SVG body. ->Asserts that an invalid text value does not crash the route and falls back without crashing. Fixes JhaSourav07#355 ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [X ] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview No visual changes — this PR only adds tests. ## 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.
1 parent 0ccffa3 commit b6fe25d

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
@@ -339,6 +339,19 @@ describe('GET /api/streak', () => {
339339

340340
expect(body).toContain('#00ff00');
341341
});
342+
343+
it('embeds a custom text color in the SVG when text is provided', async () => {
344+
const response = await GET(makeRequest({ user: 'octocat', text: 'ff0000' }));
345+
const body = await response.text();
346+
347+
expect(body).toContain('#ff0000');
348+
});
349+
350+
it('does not crash when an invalid text color is provided', async () => {
351+
const response = await GET(makeRequest({ user: 'octocat', text: 'notacolor' }));
352+
353+
expect(response.status).toBe(200);
354+
});
342355
});
343356

344357
describe('error handling', () => {

0 commit comments

Comments
 (0)