Skip to content

Commit e902357

Browse files
authored
test: resolve language chart test conflict (JhaSourav07#819)
## Description Adds a test for `LanguageChart` to clarify rendering behavior when more than 5 languages are passed to the component. Currently, `getFullDashboardData` slices the language list to 5, but `LanguageChart` itself does not enforce this limit. This PR adds a test documenting the current expected behavior and helping prevent silent regressions in the future. Fixes JhaSourav07#737 --- ## Pillar * [ ] 🎨 Pillar 1 — New Theme Design * [ ] 📐 Pillar 2 — Geometric SVG Improvement * [ ] 🕐 Pillar 3 — Timezone Logic Optimization * [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. * [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. * [x] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). * [ ] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 0ced931 + de91ef7 commit e902357

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

components/dashboard/LanguageChart.test.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,27 @@ describe('LanguageChart', () => {
4444
expect(screen.getByText('JavaScript')).toBeDefined();
4545
});
4646

47-
it('renders donut background with language color and percentage', () => {
48-
const result = buildGradientStops([{ name: 'TypeScript', percentage: 100, color: '#3178c6' }]);
47+
it('renders every language row passed to the component', () => {
48+
const languages = [
49+
{ name: 'TypeScript', percentage: 30, color: '#3178c6' },
50+
{ name: 'JavaScript', percentage: 20, color: '#f1e05a' },
51+
{ name: 'Python', percentage: 15, color: '#3572A5' },
52+
{ name: 'Go', percentage: 12, color: '#00ADD8' },
53+
{ name: 'Rust', percentage: 8, color: '#dea584' },
54+
{ name: 'Ruby', percentage: 6, color: '#701516' },
55+
{ name: 'PHP', percentage: 5, color: '#4F5D95' },
56+
{ name: 'CSS', percentage: 4, color: '#563d7c' },
57+
];
4958

50-
expect(result).toContain('#3178c6');
51-
expect(result).toContain('100%');
59+
render(<LanguageChart languages={languages} />);
60+
61+
const renderedLanguageNameElements = screen.getAllByText(
62+
(content, element) =>
63+
languages.some((language) => language.name === content) &&
64+
element?.className === 'text-[#A1A1AA]'
65+
);
66+
67+
expect(renderedLanguageNameElements).toHaveLength(8);
5268
});
5369
});
5470

0 commit comments

Comments
 (0)