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>
This commit is contained in:
Alexander Andrews
2022-10-24 16:08:18 -04:00
committed by GitHub
parent 525c1ca6d5
commit b45c70bd52
10 changed files with 324 additions and 45 deletions

View File

@@ -0,0 +1,43 @@
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');
});
})