Skip to content

Commit d72d500

Browse files
authored
test(svg): verify all supported themes produce valid SVG output (JhaSourav07#2038)
## Description Fixes JhaSourav07#719 ## Pillar - [ ] 🎨 Pillar 1 β€” New Theme Design - [ ] πŸ“ Pillar 2 β€” Geometric SVG Improvement - [ ] πŸ• Pillar 3 β€” Timezone Logic Optimization - [x] πŸ› οΈ Other (Bug fix, refactoring, docs, testing) ## Visual Preview N/A β€” Test suite addition. No user interface or SVG layout modifications were made. ## 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): ...`). - [x] 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 59b37f4 + badea7b commit d72d500

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

β€Žlib/svg/generator.test.tsβ€Ž

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from './generator';
1515
import type { BadgeParams, ContributionCalendar, StreakStats, MonthlyStats } from '../../types';
1616
import { hexColor } from './sanitizer';
17+
import { themes } from './themes';
1718

1819
describe('generateSVG', () => {
1920
const mockStats: StreakStats = {
@@ -868,6 +869,29 @@ describe('generateSVG', () => {
868869
expect(svg).not.toContain('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
869870
});
870871
});
872+
873+
describe('verify all supported themes produce valid SVG output', () => {
874+
it('generates a valid SVG and contains the theme accent color for each supported theme', () => {
875+
for (const theme of Object.values(themes)) {
876+
const svg = generateSVG(
877+
mockStats,
878+
{
879+
user: 'octocat',
880+
bg: theme.bg,
881+
text: theme.text,
882+
accent: theme.accent,
883+
speed: '8s',
884+
scale: 'linear',
885+
} as unknown as BadgeParams,
886+
mockCalendar
887+
);
888+
889+
expect(svg).toContain('<svg');
890+
expect(svg).toContain('</svg>');
891+
expect(svg.toLowerCase()).toContain(theme.accent.toLowerCase());
892+
}
893+
});
894+
});
871895
});
872896

873897
describe('generateMonthlySVG', () => {

0 commit comments

Comments
Β (0)