import { describe, expect, it } from 'vitest'; import en from '@/i18n/locales/en.json'; import ru from '@/i18n/locales/ru.json'; /** Плоский список пар «ключ → значение». */ function flatEntries(value: unknown, prefix = ''): [string, unknown][] { if (typeof value !== 'object' || value === null) { return []; } const entries: [string, unknown][] = []; for (const [key, nested] of Object.entries(value)) { const path = prefix === '' ? key : `${prefix}.${key}`; if (typeof nested === 'object' && nested !== null) { entries.push(...flatEntries(nested, path)); } else { entries.push([path, nested]); } } return entries; } /** Плоский список ключей вида `friends.empty.title`. */ function flatKeys(value: unknown): string[] { return flatEntries(value) .map(([key]) => key) .sort(); } /** * Паритет переводов: русский — основной, английский должен повторять его * ключ в ключ, иначе часть интерфейса останется без строки. */ describe('переводы', () => { it('ключи ru и en совпадают', () => { expect(flatKeys(en)).toEqual(flatKeys(ru)); }); it('нет пустых строк', () => { const empty = flatEntries(ru) .filter(([, value]) => typeof value === 'string' && value.trim() === '') .map(([key]) => key); expect(empty).toEqual([]); }); });