Files
ota-admin-portal/src/components/VehicleMap/popup.test.jsx
Alexander Andrews b45c70bd52 CEC-2654: Map polls for curren visible area (#222)
Update index.jsx
Added some tests, still don't meet  threshold

Co-authored-by: Alexander Andrews <aandrews@fiskerinc.com>
2022-10-24 13:08:18 -07:00

44 lines
1.3 KiB
JavaScript

jest.mock("../Contexts/UserContext");
import { fireEvent, render, waitFor, screen, getByText } from "@testing-library/react";
import { setToken } from "../Contexts/UserContext";
import { TEST_AUTH_OBJECT } from "../../utils/testing";
import addSnapshotSerializer from "../../utils/snapshot";
import { VehiclePopUp } from "./popup";
const renderPopup = async (online) => {
const { container } = render(
<VehiclePopUp vin={"F1SKER123456"} online={online} />
);
await waitFor(() => { });
return container;
};
describe("VehicleMap popup", () => {
beforeAll(() => {
addSnapshotSerializer(expect);
});
it("Render", async () => {
setToken(TEST_AUTH_OBJECT);
const container = await renderPopup(false);
expect(container).toMatchSnapshot();
});
it("Online: false", async () => {
setToken(TEST_AUTH_OBJECT);
const container = await renderPopup(false);
const el = screen.getAllByText('Connected', { exact: false })[0]
expect(el.parentElement.textContent).toEqual('Connected: false');
});
it("Online: true", async () => {
setToken(TEST_AUTH_OBJECT);
const container = await renderPopup(true);
const el = screen.getAllByText('Connected', { exact: false })[0]
expect(el.parentElement.textContent).toEqual('Connected: true');
});
})