Skip to content

Commit 48d7e3f

Browse files
authored
test(i18n): add French badge label coverage (JhaSourav07#3149)
## Description Fixes JhaSourav07#2337 Adds focused Vitest coverage for French (`fr`) badge label translations in `lib/i18n/badgeLabels.ts`. Tests verify: * The `fr` language key exists in the labels dictionary * `getLabels('fr')` returns the expected French translations * Language code casing is handled correctly * All required translation properties are non-empty strings * Mock SVG rendering outputs the translated French labels ## 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 — 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`). * [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.
2 parents eb265c1 + 7dffdd3 commit 48d7e3f

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

lib/i18n/languages/fr.test.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { describe, expect, it } from 'vitest';
2+
import { getLabels, labels } from '../badgeLabels';
3+
4+
const requiredKeys = [
5+
'CURRENT_STREAK',
6+
'ANNUAL_SYNC_TOTAL',
7+
'PEAK_STREAK',
8+
'COMMITS_THIS_MONTH',
9+
'VS_LAST_MONTH',
10+
] as const;
11+
12+
const expectedFrenchLabels = {
13+
CURRENT_STREAK: 'SÉRIE_ACTUELLE',
14+
ANNUAL_SYNC_TOTAL: 'TOTAL_ANNUEL',
15+
PEAK_STREAK: 'SÉRIE_MAXIMALE',
16+
COMMITS_THIS_MONTH: 'COMMITS CE MOIS',
17+
VS_LAST_MONTH: 'vs mois dernier',
18+
};
19+
20+
function renderMockBadge(lang: string) {
21+
const badgeLabels = getLabels(lang);
22+
23+
return `
24+
<svg role="img" data-lang="${lang}">
25+
<text>${badgeLabels.CURRENT_STREAK}</text>
26+
<text>${badgeLabels.ANNUAL_SYNC_TOTAL}</text>
27+
<text>${badgeLabels.PEAK_STREAK}</text>
28+
<text>${badgeLabels.COMMITS_THIS_MONTH}</text>
29+
<text>${badgeLabels.VS_LAST_MONTH}</text>
30+
</svg>
31+
`;
32+
}
33+
34+
describe('French badge labels', () => {
35+
it('includes the fr language key in the labels dictionary', () => {
36+
expect(labels.fr).toBeDefined();
37+
});
38+
39+
it('returns the exact French translation mapping through getLabels', () => {
40+
expect(getLabels('fr')).toEqual(expectedFrenchLabels);
41+
});
42+
43+
it('returns the French mapping when lang code casing differs', () => {
44+
expect(getLabels('FR')).toEqual(expectedFrenchLabels);
45+
});
46+
47+
it('sets every required French label to a non-empty string', () => {
48+
const frenchLabels = getLabels('fr');
49+
50+
for (const key of requiredKeys) {
51+
expect(typeof frenchLabels[key]).toBe('string');
52+
expect(frenchLabels[key].trim().length).toBeGreaterThan(0);
53+
}
54+
});
55+
56+
it('renders a mock SVG with French translated labels', () => {
57+
const svg = renderMockBadge('fr');
58+
59+
expect(svg).toContain('data-lang="fr"');
60+
61+
for (const value of Object.values(expectedFrenchLabels)) {
62+
expect(svg).toContain(value);
63+
}
64+
});
65+
});

0 commit comments

Comments
 (0)