* CEC-2628 - Display IP in digital twin in portal (#251) * CEC-3453 Update security dll instructions (#252) * CEC-2752-Add-Mobile-Issue-Tracker (#250) * first commit * removed comments * remove more comments * fix build issues * fix unused vars * update snapshot * fix test * Fix connect ECONNREFUSED 127.0.0.1:80 * Test Magna side menu * attempt to pass test * fix test * remove comments * fix some code smells * fix test * resolve comments * fix bug * resolved comments * resolve comments * resolve comments * update snapshot * resolved comments Co-authored-by: jwu-fisker <jwu@fiskerinc.com> * Cec 2752 small fix (#253) * first commit * removed comments * remove more comments * fix build issues * fix unused vars * update snapshot * fix test * Fix connect ECONNREFUSED 127.0.0.1:80 * Test Magna side menu * attempt to pass test * fix test * remove comments * fix some code smells * fix test * resolve comments * fix bug * resolved comments * resolve comments * resolve comments * update snapshot * resolved comments * small fix Co-authored-by: jwu-fisker <jwu@fiskerinc.com> Co-authored-by: Paul Adamsen <117673433+pauladamseniii@users.noreply.github.com> Co-authored-by: das31 <31259710+das31@users.noreply.github.com>
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
jest.mock("../Contexts/UserContext");
|
|
jest.mock("../../services/superset");
|
|
|
|
import { render, screen, waitFor } from "@testing-library/react";
|
|
import { BrowserRouter } from "react-router-dom";
|
|
import addSnapshotSerializer from "../../utils/snapshot";
|
|
import { TEST_AUTH_OBJECT_FISKER, TEST_AUTH_OBJECT_MAGNA } from "../../utils/testing";
|
|
import { setToken, UserProvider } from "../Contexts/UserContext";
|
|
import SideMenu from "./SideMenu";
|
|
|
|
const renderMenu = async () => {
|
|
const { container } = render(
|
|
<UserProvider>
|
|
<BrowserRouter>
|
|
<SideMenu />
|
|
</BrowserRouter>
|
|
</UserProvider>
|
|
);
|
|
await waitFor(() => {});
|
|
return container;
|
|
};
|
|
|
|
describe("SideMenu", () => {
|
|
beforeAll(() => {
|
|
addSnapshotSerializer(expect);
|
|
});
|
|
|
|
it("Unauthenticated", async () => {
|
|
setToken({ idToken: { jwtToken: null } });
|
|
const container = await renderMenu();
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
|
|
it("Authenticated", async () => {
|
|
setToken(TEST_AUTH_OBJECT_FISKER);
|
|
const container = await renderMenu();
|
|
await waitFor(() => {
|
|
expect(screen.getByText("Datascope")).toBeInTheDocument();
|
|
});
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
|
|
it("Magna Authenticated", async () => {
|
|
setToken(TEST_AUTH_OBJECT_MAGNA);
|
|
const container = await renderMenu();
|
|
await waitFor(() => {
|
|
expect(screen.getByText("Tools")).toBeInTheDocument();
|
|
});
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
});
|