From 3fde6bd730a7260b4bf1434c8d9785c2b6149098 Mon Sep 17 00:00:00 2001 From: Polidoro-root <54002172+Polidoro-root@users.noreply.github.com> Date: Mon, 9 Sep 2024 09:49:47 -0300 Subject: [PATCH] I18n: Add constants value tests to avoid typos (#93070) --- .../internationalization/constants.test.ts | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/public/app/core/internationalization/constants.test.ts b/public/app/core/internationalization/constants.test.ts index e0dff39d343..8e50e6f34bf 100644 --- a/public/app/core/internationalization/constants.test.ts +++ b/public/app/core/internationalization/constants.test.ts @@ -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);