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 } 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);
    addSnapshotSerializer(expect);
  });

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