jest.mock("../../Contexts/StatusContext");
jest.mock("../../Contexts/UserContext");
jest.mock("../../../services/CANSignalAPI");
jest.useFakeTimers();
jest.setSystemTime(new Date(2023, 3, 1, 6, 30, 45, 100));

import { render, waitFor } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";
import addSnapshotSerializer from "../../../utils/snapshot";
import { TEST_AUTH_OBJECT_FISKER } from "../../../utils/testing";

import { StatusProvider } from "../../Contexts/StatusContext";
import { setToken, UserProvider } from "../../Contexts/UserContext";
import DTCTimeline from "./index";

const renderDTCTimeline = async () => {
  const { container } = render(
    <StatusProvider>
      <UserProvider>
        <BrowserRouter>
          <DTCTimeline id="TESTVIN1234567890" />
        </BrowserRouter>
      </UserProvider>
    </StatusProvider>
  );
  await waitFor(() => {
    /* render */
  });
  return container;
};

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

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