jest.mock("../../Contexts/VehicleContext");
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 { BrowserRouter } from "react-router-dom";

import { VehicleProvider } from "../../Contexts/VehicleContext";
import { StatusProvider } from "../../Contexts/StatusContext";
import { UserProvider, setToken } from "../../Contexts/UserContext";
import { TEST_AUTH_OBJECT } from "../../../utils/testing";
import MainForm from "./index";
import addSnapshotSerializer from "../../../utils/snapshot";

const renderVehicleTable = async () => {
  const { container } = render(
    <VehicleProvider>
      <StatusProvider>
        <UserProvider>
          <BrowserRouter>
            <MainForm />
          </BrowserRouter>
        </UserProvider>
      </StatusProvider>
    </VehicleProvider>
  );
  await waitFor(() => {
    /* render */
  });
  return container;
};

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

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