import { render } from "@testing-library/react"; import fallbackLangData from "../locales/en.json"; import Trans from "./Trans"; describe("Test ", () => { it("should translate the the strings correctly", () => { //@ts-ignore fallbackLangData.transTest = { key1: "Hello {{audience}}", key2: "Please click the button to continue.", key3: "Please click {{location}} to continue.", key4: "Please click {{location}} to continue.", key5: "Please click the button to continue.", }; const { getByTestId } = render( <>
{el}} />
{el}} location="the button" />
{el}} location="the button" bold={(el) => {el}} />
{el}} />
, ); expect(getByTestId("test1").innerHTML).toEqual("Hello world"); expect(getByTestId("test2").innerHTML).toEqual( `Please click the button to continue.`, ); expect(getByTestId("test3").innerHTML).toEqual( `Please click the button to continue.`, ); expect(getByTestId("test4").innerHTML).toEqual( `Please click the button to continue.`, ); expect(getByTestId("test5").innerHTML).toEqual( `Please click the button to continue.`, ); }); });