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

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

import { FleetProvider } from "../../Contexts/FleetContext";
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 renderFleetUpdate = async () => {
  const { container } = render(
    <FleetProvider>
      <StatusProvider>
        <UserProvider>
          <BrowserRouter>
            <MainForm />
          </BrowserRouter>
        </UserProvider>
      </StatusProvider>
    </FleetProvider>
  );
  await waitFor(() => {
    /* render */
  });
  return container;
};

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

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