jest.mock("../../Contexts/ManifestsContext");
jest.mock("../../Contexts/UserContext");

import React from "react";
import { render, waitFor } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";

import { ManifestsProvider } from "../../Contexts/ManifestsContext";
import { UserProvider, setToken } from "../../Contexts/UserContext";
import { StatusProvider } from "../../Contexts/StatusContext";
import ManifestUpdate from ".";
import { TEST_AUTH_OBJECT_FISKER } from "../../../utils/testing";
import addSnapshotSerializer from "../../../utils/snapshot";

const renderManifestUpdate = async () => {
  const { container } = render(
    <UserProvider>
    <BrowserRouter>
      <StatusProvider>
        <ManifestsProvider>
          <ManifestUpdate />
        </ManifestsProvider>
      </StatusProvider>
    </BrowserRouter>
  </UserProvider>);
  await waitFor(() => {
    /* render */
  });

  return container;
}


describe("Manifest Details Component", () => {
  beforeAll(() => {
    setToken(TEST_AUTH_OBJECT_FISKER);
    addSnapshotSerializer(expect);
  });

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