Skip to content

Commit 05741d1

Browse files
authored
test(languageColors): add language colors coverage (JhaSourav07#1206)
## Description Added Vitest coverage for LANGUAGE_COLORS in lib/svg/languageColors.test.ts. This PR adds 6 test cases covering: - TypeScript color value - JavaScript color value - Python color existence - Valid 6-digit hex color format - Minimum language count - Empty language key validation Fixes JhaSourav07#1016 ## Testing - npm test -- lib/svg/languageColors.test.ts - 1 test file passed - 6 tests passed - npm run typecheck - Passed - npx vitest run - 50 test files passed - 684 tests passed - npm run lint - Passed with 0 errors - 2 pre-existing warnings in components/dashboard/ComparisonStatsCard.test.tsx ## 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. This PR only adds test coverage and does not change the UI or SVG output. ## 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. - [ ] 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 b04d6a8 + e1a460d commit 05741d1

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

lib/svg/languageColors.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { describe, expect, it } from 'vitest';
2+
3+
import { LANGUAGE_COLORS } from './languageColors';
4+
5+
describe('LANGUAGE_COLORS', () => {
6+
it('contains the correct TypeScript color', () => {
7+
expect(LANGUAGE_COLORS.TypeScript).toBe('#3178c6');
8+
});
9+
10+
it('contains the correct JavaScript color', () => {
11+
expect(LANGUAGE_COLORS.JavaScript).toBe('#f1e05a');
12+
});
13+
14+
it('defines Python color', () => {
15+
expect(LANGUAGE_COLORS.Python).toBeDefined();
16+
});
17+
18+
it('uses valid 6-digit hex colors for every language', () => {
19+
for (const color of Object.values(LANGUAGE_COLORS)) {
20+
expect(color).toMatch(/^#[0-9a-fA-F]{6}$/);
21+
}
22+
});
23+
24+
it('contains at least 20 languages', () => {
25+
expect(Object.keys(LANGUAGE_COLORS).length).toBeGreaterThanOrEqual(20);
26+
});
27+
28+
it('does not contain empty language names', () => {
29+
for (const language of Object.keys(LANGUAGE_COLORS)) {
30+
expect(language.trim()).not.toBe('');
31+
}
32+
});
33+
});

0 commit comments

Comments
 (0)