jest.mock("../../Contexts/FleetContext");
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 { setToken } from "../../Contexts/UserContext";
import { TEST_AUTH_OBJECT } from "../../../utils/testing";
import VehiclesTab from "./VehiclesTab";
import addSnapshotSerializer from "../../../utils/snapshot";

const renderVehiclesTab = async () => {
  const { container } = render(
    <BrowserRouter>
      <VehiclesTab name="US-TEST" />
    </BrowserRouter>
  );
  await waitFor(() => {
    /* render */
  });
  return container;
};

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

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