Files
jobtrackingapp/job-tracker-ui/src/translation-catalogue.test.ts
T

22 lines
932 B
TypeScript

import { translations } from './i18n/translations';
const placeholders = (text: string) => [...new Set(text.match(/\{\w+\}/g) ?? [])].sort();
test('English and Bokmål expose the same UI message keys', () => {
expect(Object.keys(translations.nb).sort()).toEqual(Object.keys(translations.en).sort());
});
test('Bokmål preserves every English substitution variable', () => {
const mismatches = Object.entries(translations.en).filter(([key, text]) =>
JSON.stringify(placeholders(text)) !== JSON.stringify(placeholders(translations.nb[key as keyof typeof translations.en]))
).map(([key]) => key);
expect(mismatches).toEqual([]);
});
test('supported UI catalogues contain no blank messages', () => {
const blanks = Object.entries(translations).flatMap(([language, messages]) =>
Object.entries(messages).filter(([, text]) => !text.trim()).map(([key]) => `${language}.${key}`)
);
expect(blanks).toEqual([]);
});