diff --git a/packages/record/src/utils.spec.ts b/packages/record/src/utils.spec.ts index 922a399a..6bd4e4ab 100644 --- a/packages/record/src/utils.spec.ts +++ b/packages/record/src/utils.spec.ts @@ -1,4 +1,15 @@ -import { expFormat } from "./utils"; +import Yaml from "js-yaml"; +import en_us from "../i18n/en-us.yaml"; +import eu from "../i18n/eu.yaml"; +import fr from "../i18n/fr.yaml"; +import hu from "../i18n/hu.yaml"; +import it from "../i18n/it.yaml"; +import ja from "../i18n/ja.yaml"; +import nl from "../i18n/nl.yaml"; +import pt_br from "../i18n/pt-br.yaml"; +import pt from "../i18n/pt.yaml"; +import { TranslationNotFoundError } from "./errors"; +import { expFormat, getTranslation } from "./utils"; test("expFormat convert written text to format well in HTML", () => { expect(expFormat("abcdefg")).toStrictEqual("abcdefg"); @@ -18,3 +29,27 @@ test("expFormat convert written text to format well in HTML", () => { "    Tabbed text", ); }); + +test("Get translation file for specified locale", () => { + const translations = { + ja, + pt, + eu, + fr, + hu, + it, + nl, + "en-us": en_us, + "pt-br": pt_br, + }; + + for (const [k, v] of Object.entries(translations)) { + expect(getTranslation(new Intl.Locale(k))).toStrictEqual(Yaml.load(v)); + } + + expect(pt_br).not.toStrictEqual(pt); + + expect(() => getTranslation(new Intl.Locale("not-a2code"))).toThrow( + TranslationNotFoundError, + ); +});