jest.mock("../../Contexts/CarUpdatesContext");
jest.mock("../../Contexts/StatusContext");
jest.mock("../../Contexts/UserContext");
jest.mock("@material-ui/core/utils/unstable_useId", () =>
  jest.fn().mockReturnValue("mui-test-id")
);
import { render, waitFor } from "@testing-library/react";
import { MemoryRouter, Route } from "react-router-dom";
import { CarUpdatesProvider } from "../../Contexts/CarUpdatesContext";
import { StatusProvider } from "../../Contexts/StatusContext";
import { UserProvider, setToken } from "../../Contexts/UserContext";
import { TEST_AUTH_OBJECT_FISKER } from "../../../utils/testing";
import MainForm from "./index";
import addSnapshotSerializer from "../../../utils/snapshot";

const renderSUMSAdd = async () => {
  const { container } = render(
    <CarUpdatesProvider>
      <StatusProvider>
        <UserProvider>
          <MemoryRouter initialEntries={["/sums/add-rxswin/2023.03.00.00.E"]}>
            <Route path="/sums/add-rxswin/:sums_version">
              <MainForm sums_version="2023.03.00.00.E" />
            </Route>
          </MemoryRouter>
        </UserProvider>
      </StatusProvider>
    </CarUpdatesProvider>
  );
  await waitFor(() => {
    /* render */
  });
  return container;
};

describe("SUMSAdd", () => {
  beforeAll(() => {
    addSnapshotSerializer(expect);
  });

  it("Render", async () => {
    setToken(TEST_AUTH_OBJECT_FISKER);
    const container = await renderSUMSAdd();
    expect(container).toMatchSnapshot();
  });
});
