import {TEST_AUTH_OBJECT_FISKER} from "../../../utils/testing";

jest.mock("../../Contexts/CANFiltersContext");
jest.mock("../../Contexts/StatusContext");
jest.mock("../../Contexts/UserContext");

import { render, waitFor } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";

import { CANFiltersProvider } from "../../Contexts/CANFiltersContext";
import { StatusProvider } from "../../Contexts/StatusContext";
import { UserProvider, setToken } from "../../Contexts/UserContext";
import MainForm from "./index";
import addSnapshotSerializer from "../../../utils/snapshot";

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

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

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