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

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

import { UserProvider, setToken } from "../../Contexts/UserContext";
import { StatusProvider } from "../../Contexts/StatusContext";
import ManifestList from ".";
import { TEST_AUTH_OBJECT_FISKER } from "../../../utils/testing";

const Page = (
  <UserProvider>
    <BrowserRouter>
      <StatusProvider>
        <ManifestList />
      </StatusProvider>
    </BrowserRouter>
  </UserProvider>
);

describe("Manifest List Component", () => {
  beforeAll(() => {
    setToken(TEST_AUTH_OBJECT_FISKER);
  });

  it("adjusts the active state on switch to archived tab", async () => {
    render(Page);

    const archiveActionEl = screen.getByText("Archive");
    fireEvent.click(screen.getByText("Archived"));
    expect(archiveActionEl.innerHTML).toBe("Activate");
  });
});
