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 React from "react";
import {render, waitFor} from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";

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

const renderFleetsTab = async () => {
  const {container} = render(
    <StatusProvider>
      <UserProvider>
        <VehicleProvider>
          <BrowserRouter>
            <FleetsTab vin="TESTVIN1234567890"/>
          </BrowserRouter>
        </VehicleProvider>
      </UserProvider>
    </StatusProvider>
  );
  await waitFor(() => {
    /* render */
  });
  return container;
};

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

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