Add tests for some tools functions (#1377)

*  Add tests for some tools functions

* 🐛 Build issue with language definition
This commit is contained in:
Meier Lukas
2023-09-07 21:32:29 +02:00
committed by GitHub
parent 7b2ce22bca
commit 391c074ef9
5 changed files with 219 additions and 11 deletions

View File

@@ -13,7 +13,7 @@ export type Language = {
locale: string;
};
export const languages: Language[] = [
export const languages = [
{
shortName: 'de',
originalName: 'Deutsch',
@@ -93,6 +93,7 @@ export const languages: Language[] = [
originalName: 'LOLCAT',
translatedName: 'LOLCAT',
emoji: '🐱',
country: 'LOL',
locale: 'en-gb',
},
// Norwegian
@@ -224,9 +225,11 @@ export const languages: Language[] = [
originalName: 'Magyar',
translatedName: 'Hungarian',
emoji: '🇭🇺',
country: 'HU',
locale: 'hu',
},
];
] as const satisfies Readonly<Language[]>;
export const getLanguageByCode = (code: string | null) =>
languages.find((language) => language.shortName === code) ?? languages[languages.length - 1];
languages.find((language) => language.shortName === code) ??
languages.find((x) => x.locale === 'en-gb')!;