Files
ota-admin-portal/src/components/Layouts/SideMenu.test.jsx
John Wu 93926d3c01 CEC-1230 Datascope opens iframe dashboard (#174)
* CEC-1230 Datascope opens iframe dashboard

* Clean up
2022-08-04 11:59:02 -07:00

39 lines
989 B
JavaScript

jest.mock("../Contexts/UserContext");
import { render, waitFor } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";
import { UserProvider, setToken } from "../Contexts/UserContext";
import { TEST_AUTH_OBJECT } from "../../utils/testing";
import SideMenu from "./SideMenu";
import addSnapshotSerializer from "../../utils/snapshot";
const renderMenu = async () => {
const { container } = render(
<UserProvider>
<BrowserRouter>
<SideMenu />
</BrowserRouter>
</UserProvider>
);
await waitFor(() => {});
return container;
};
describe("SideMenu", () => {
beforeAll(() => {
addSnapshotSerializer(expect);
});
it("Unauthenticated", async () => {
setToken(null);
const container = await renderMenu();
expect(container).toMatchSnapshot();
});
it("Authenticated", async () => {
setToken(TEST_AUTH_OBJECT);
const container = await renderMenu();
expect(container).toMatchSnapshot();
});
});