diff --git a/__tests__/components/popups/submission/_partials/Header.test.tsx b/__tests__/components/popups/submission/_partials/Header.test.tsx new file mode 100644 index 000000000..c60cf6ec0 --- /dev/null +++ b/__tests__/components/popups/submission/_partials/Header.test.tsx @@ -0,0 +1,28 @@ +import SubmissionPopup from "@/components/popups/submission/_partials/Header"; +import "@testing-library/jest-dom"; +import { render, screen, fireEvent } from "@testing-library/react"; + +describe("SubmissionPopup", () => { + const mockOnClose = jest.fn(); + + + it("renders the component with correct text", () => { + render(); + expect(screen.getByText("communities.submission")).toBeInTheDocument(); + }); + + it("Invokes the onClose function when the arrow icon is clicked", () => { + render(); + const arrowButton = screen.getByTestId("arrow-button"); + fireEvent.click(arrowButton); + expect(mockOnClose).toHaveBeenCalled(); + }); + + it("Invokes the onClose function when the close button is clicked", () => { + render(); + const closeButton = screen.getByRole("button"); + fireEvent.click(closeButton); + expect(mockOnClose).toHaveBeenCalled(); + }); + +}); diff --git a/__tests__/components/popups/submission/index.test.tsx b/__tests__/components/popups/submission/index.test.tsx new file mode 100644 index 000000000..ee9a1451f --- /dev/null +++ b/__tests__/components/popups/submission/index.test.tsx @@ -0,0 +1,27 @@ +import SubmissionPopup from "@/components/popups/submission"; +import { renderWithRedux } from "@__mocks__/renderWithRedux"; +import "@testing-library/jest-dom"; +import { fireEvent, screen } from "@testing-library/react"; +describe("SubmissionPopup", () => { + + const mockOnClose = jest.fn(); + + it("renders the popup when show is true", () => { + renderWithRedux(); + expect(screen.getByTestId("overlay")).toBeInTheDocument(); + expect(screen.getByText("communities.submission")).toBeInTheDocument(); + expect(screen.getByTestId("viewId")).toBeInTheDocument(); + }); + + it("does not render the popup when show is false", () => { + renderWithRedux(); + expect(screen.queryByTestId("overlay")).not.toBeInTheDocument(); + }); + + it("calls the onClose function when the close button is clicked", () => { + renderWithRedux(); + const closeButton = screen.getByTestId("overlay"); + fireEvent.click(closeButton); + expect(mockOnClose).toHaveBeenCalled(); + }); +}); diff --git a/src/components/popups/submission/_partials/Header.tsx b/src/components/popups/submission/_partials/Header.tsx index d6456939d..768fb1fd5 100644 --- a/src/components/popups/submission/_partials/Header.tsx +++ b/src/components/popups/submission/_partials/Header.tsx @@ -26,7 +26,7 @@ export default function SubmissionPopup({ onClose }: SubmissionPopup): ReactElem const { t } = useTranslation(); return (
-
+
{t("communities.submission")}