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 { StatusProvider } from "../../Contexts/StatusContext";
import { UserProvider, setToken } from "../../Contexts/UserContext";
import { TEST_AUTH_OBJECT_FISKER } from "../../../utils/testing";
import DigitalTwinTab from "./DigitalTwinTab";
import addSnapshotSerializer from "../../../utils/snapshot";

const renderDetailsTab = async () => {
  const { container } = render(
    <StatusProvider>
      <UserProvider>
        <DigitalTwinTab vin="TESTVIN1234567890" />
      </UserProvider>
    </StatusProvider>
  );
  await waitFor(() => {
    /* render */
  });
  return container;
};

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

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