jest.mock("../../Contexts/CANFiltersContext");
jest.mock("../../Contexts/StatusContext");
jest.mock("../../Contexts/UserContext");
jest.mock("../../../services/vehiclesAPI");
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 addSnapshotSerializer from "../../../utils/snapshot";
import { TEST_AUTH_OBJECT_FISKER } from "../../../utils/testing";
import { CANFiltersProvider } from "../../Contexts/CANFiltersContext";
import { StatusProvider } from "../../Contexts/StatusContext";
import { setToken, UserProvider } from "../../Contexts/UserContext";
import MainForm from "./CarUpdatesTab";

const renderCarUpdatesTab = async () => {
  const { container } = render(
    <CANFiltersProvider>
      <StatusProvider>
        <UserProvider>
          <BrowserRouter>
            <MainForm vin="TESTVIN1234567890" />
          </BrowserRouter>
        </UserProvider>
      </StatusProvider>
    </CANFiltersProvider>
  );
  await waitFor(() => {
    /* render */
  });
  return container;
};

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

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