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")
);
jest.useFakeTimers();
jest.setSystemTime(new Date(2024, 6, 18, 6, 30, 45, 100));

import { BrowserRouter } from "react-router-dom";
import { VehicleProvider } from "../../Contexts/VehicleContext";
import { render, waitFor } from "@testing-library/react";
import { StatusProvider } from "../../Contexts/StatusContext";
import { setToken, UserProvider } from "../../Contexts/UserContext";
import MainForm from "./TRexLogsTab";
import addSnapshotSerializer from "../../../utils/snapshot";
import { TEST_AUTH_OBJECT_FISKER } from "../../../utils/testing";
import React from "react";

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

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

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