Skip to content

Commit d8c7474

Browse files
committed
test(i18n): add Japanese badge label coverage
1 parent 2e604a1 commit d8c7474

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

lib/i18n/languages/ja.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 expectedJapaneseLabels = {
13+
CURRENT_STREAK: '現在のストリーク',
14+
ANNUAL_SYNC_TOTAL: '年間合計',
15+
PEAK_STREAK: '最高ストリーク',
16+
COMMITS_THIS_MONTH: '今月のコミット数',
17+
VS_LAST_MONTH: '先月比',
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('Japanese badge labels', () => {
35+
it('includes the ja language key in the labels dictionary', () => {
36+
expect(labels.ja).toBeDefined();
37+
});
38+
39+
it('returns the exact Japanese translation mapping through getLabels', () => {
40+
expect(getLabels('ja')).toEqual(expectedJapaneseLabels);
41+
});
42+
43+
it('returns the Japanese mapping when lang code casing differs', () => {
44+
expect(getLabels('JA')).toEqual(expectedJapaneseLabels);
45+
});
46+
47+
it('sets every required Japanese label to a non-empty string', () => {
48+
const japaneseLabels = getLabels('ja');
49+
50+
for (const key of requiredKeys) {
51+
expect(typeof japaneseLabels[key]).toBe('string');
52+
expect(japaneseLabels[key].trim().length).toBeGreaterThan(0);
53+
}
54+
});
55+
56+
it('renders a mock SVG with Japanese translated labels', () => {
57+
const svg = renderMockBadge('ja');
58+
59+
expect(svg).toContain('data-lang="ja"');
60+
61+
for (const value of Object.values(expectedJapaneseLabels)) {
62+
expect(svg).toContain(value);
63+
}
64+
});
65+
});

0 commit comments

Comments
 (0)