Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions __tests__/components/cards/TranslationBox.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import "@testing-library/jest-dom";
import { screen } from "@testing-library/react";
import TranslationBox from "@/components/cards/TranslationBox";
import { renderWithRedux } from "../../../__mocks__/renderWithRedux";
// import { Translate } from "@/utilities/Translate";

jest.mock("next/router", () => ({
useRouter() {
return {
route: "/",
pathname: "",
query: "",
locale: "",
};
},
}));

jest.mock("react-i18next", () => ({
useTranslation: () => ({
t: (key: string) => key,
}),
}));

jest.mock("../../../src/utilities/Translate", () => ({
Translate: jest.fn(),
}));

// jest.mock('../../../src/components/cards/TranslationBox', ()=>{
// getLocaleName: jest.fn(()=>'English')
// })

// // const getLocaleNameMock = jest.fn(()=>{
// // 'English'
// // )

describe("TranslationBOX", () => {
it("should render the componet", () => {
renderWithRedux(<TranslationBox text="test text" defaultLocale="en" />);
expect(screen.getByText("test text")).toBeInTheDocument();
});

// it("should show loading state during translation", async () => {
// renderWithRedux(<TranslationBox text="test text" defaultLocale="en" />);
// fireEvent.click(await screen.findByText(/^ui.translated/));
// expect(Translate).toHaveBeenCalled();
// expect(screen.getByText("Translating...")).toBeInTheDocument();
// });


});
1 change: 1 addition & 0 deletions src/components/cards/TranslationBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export default function TranslationBox({ text, defaultLocale, disabled, textCont
}, [translated]);

const translatable = currentLocale !== defaultLocale && !disabled && getLocaleName(defaultLocale);
console.log({description} , getLocaleName(currentLocale))
return (
<div className="relative w-full pb-5">
{currentText ? (
Expand Down