I18n: Add constants value tests to avoid typos (#93070)

This commit is contained in:
Polidoro-root 2024-09-09 09:49:47 -03:00 committed by GitHub
parent 3aeb8d390e
commit 3fde6bd730
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,8 +1,30 @@
import { uniqBy } from 'lodash';
import { LANGUAGES, VALID_LANGUAGES } from './constants';
import {
BRAZILIAN_PORTUGUESE,
CHINESE_SIMPLIFIED,
DEFAULT_LANGUAGE,
ENGLISH_US,
FRENCH_FRANCE,
GERMAN_GERMANY,
LANGUAGES,
PSEUDO_LOCALE,
SPANISH_SPAIN,
VALID_LANGUAGES,
} from './constants';
describe('internationalization constants', () => {
it('should have set the constants correctly', () => {
expect(ENGLISH_US).toBe('en-US');
expect(FRENCH_FRANCE).toBe('fr-FR');
expect(SPANISH_SPAIN).toBe('es-ES');
expect(GERMAN_GERMANY).toBe('de-DE');
expect(BRAZILIAN_PORTUGUESE).toBe('pt-BR');
expect(CHINESE_SIMPLIFIED).toBe('zh-Hans');
expect(PSEUDO_LOCALE).toBe('pseudo-LOCALE');
expect(DEFAULT_LANGUAGE).toBe(ENGLISH_US);
});
it('should not have duplicate languages codes', () => {
const uniqLocales = uniqBy(LANGUAGES, (v) => v.code);
expect(LANGUAGES).toHaveLength(uniqLocales.length);