mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-17 19:02:07 +08:00
24 lines
1.3 KiB
TypeScript
24 lines
1.3 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
const source = readFileSync(new URL('./Sidebar.tsx', import.meta.url), 'utf8');
|
|
const locales = ['zh-CN', 'zh-TW', 'en-US', 'ja-JP', 'de-DE', 'ru-RU'] as const;
|
|
|
|
describe('Sidebar routine definition tab i18n', () => {
|
|
it('localizes routine definition tab titles', () => {
|
|
expect(source).not.toContain('title: `${typeLabel}: ${routineName}`');
|
|
expect(source.match(/title: t\('sidebar\.tab\.routine_definition'/g) || []).toHaveLength(2);
|
|
expect(source.match(/t\(routineType === 'PROCEDURE' \? 'sidebar\.object\.procedure' : 'sidebar\.object\.function'\)/g) || []).toHaveLength(4);
|
|
});
|
|
|
|
it('keeps routine definition tab catalog placeholders aligned', () => {
|
|
locales.forEach((locale) => {
|
|
const catalog = JSON.parse(readFileSync(new URL(`../../../shared/i18n/${locale}.json`, import.meta.url), 'utf8')) as Record<string, string>;
|
|
expect(catalog['sidebar.tab.routine_definition'], `${locale}:routine definition type`).toContain('{{type}}');
|
|
expect(catalog['sidebar.tab.routine_definition'], `${locale}:routine definition name`).toContain('{{name}}');
|
|
expect(catalog['sidebar.object.function'], `${locale}:function`).toBeTruthy();
|
|
expect(catalog['sidebar.object.procedure'], `${locale}:procedure`).toBeTruthy();
|
|
});
|
|
});
|
|
});
|