Skip to content

Commit ffc15ed

Browse files
Merge branch 'main' into docs/cache-getorset-comments
2 parents f778bda + 48d7e3f commit ffc15ed

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)