diff --git a/services/ui-src/src/components/layout/Header.test.tsx b/services/ui-src/src/components/layout/Header.test.tsx index 309a8ae75..4b7b2aa53 100644 --- a/services/ui-src/src/components/layout/Header.test.tsx +++ b/services/ui-src/src/components/layout/Header.test.tsx @@ -16,7 +16,7 @@ const mockedUseStore = useStore as jest.MockedFunction; const headerComponent = ( -
{}} /> +
); @@ -24,17 +24,11 @@ const headerComponent = ( const reportComponent = ( -
{}} /> +
); -/* - * jest.mock("utils/reports/routing", () => ({ - * isReportFormPage: jest.fn(() => true), - * })); - */ - describe("
", () => { describe("Test Header", () => { beforeEach(() => { diff --git a/services/ui-src/src/components/menus/Menu.test.tsx b/services/ui-src/src/components/menus/Menu.test.tsx index a733394aa..1bdd8058e 100644 --- a/services/ui-src/src/components/menus/Menu.test.tsx +++ b/services/ui-src/src/components/menus/Menu.test.tsx @@ -1,13 +1,27 @@ import { render, screen } from "@testing-library/react"; -// utils -import { RouterWrappedComponent } from "utils/testing/setupJest"; +import userEvent from "@testing-library/user-event"; //components import { Menu } from "components"; +// utils +import { + mockUserContext, + RouterWrappedComponent, +} from "utils/testing/setupJest"; +import { UserContext } from "utils"; import { testA11y } from "utils/testing/commonTests"; +const mockLogout = jest.fn(); + +const mockContext = { + ...mockUserContext, + logout: mockLogout, +}; + const menuComponent = ( - {}} /> + + + ); @@ -17,5 +31,12 @@ describe("", () => { expect(screen.getByTestId("header-menu-dropdown-button")).toBeVisible(); }); + test("Menu button logout fires logout function", async () => { + render(menuComponent); + const logoutButton = screen.getByText("Log Out"); + await userEvent.click(logoutButton); + expect(mockLogout).toHaveBeenCalledTimes(1); + }); + testA11y(menuComponent); });