Skip to content

Commit 7d0b747

Browse files
authored
Add LanguageChart donut background style test (JhaSourav07#785)
## Description Added a test for `LanguageChart` to verify the donut chart gradient logic includes the expected language color and percentage. Fixes JhaSourav07#738 ## 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 UI changes. 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`). - [ ] 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). - [ ] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents a29080d + 90d9cc7 commit 7d0b747

3 files changed

Lines changed: 37 additions & 14 deletions

File tree

β€Žcomponents/dashboard/LanguageChart.test.tsxβ€Ž

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import { render, screen } from '@testing-library/react';
33
import { describe, expect, it, vi } from 'vitest';
4-
import LanguageChart from './LanguageChart';
5-
import { buildGradientStops } from './LanguageChart';
4+
import LanguageChart, { buildGradientStops } from './LanguageChart';
65

76
vi.mock('framer-motion', () => ({
87
motion: {
@@ -44,6 +43,13 @@ describe('LanguageChart', () => {
4443
expect(screen.getAllByText('TypeScript')).toHaveLength(2);
4544
expect(screen.getByText('JavaScript')).toBeDefined();
4645
});
46+
47+
it('renders donut background with language color and percentage', () => {
48+
const result = buildGradientStops([{ name: 'TypeScript', percentage: 100, color: '#3178c6' }]);
49+
50+
expect(result).toContain('#3178c6');
51+
expect(result).toContain('100%');
52+
});
4753
});
4854

4955
describe('buildGradientStops', () => {

β€Žcomponents/dashboard/LanguageChart.tsxβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default function LanguageChart({ languages }: { languages: LanguageData[]
5858
<div className="relative w-36 h-36 flex items-center justify-center">
5959
{/* Donut */}
6060
<motion.div
61+
data-testid="donut-chart"
6162
initial={{ rotate: -90, scale: 0.8, opacity: 0 }}
6263
animate={{ rotate: 0, scale: 1, opacity: 1 }}
6364
transition={{ duration: 0.8, type: 'spring', stiffness: 80 }}

β€Žpackage-lock.jsonβ€Ž

Lines changed: 28 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
Β (0)