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

import { render, waitFor } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";
import { UserProvider, setToken } from "../Contexts/UserContext";
import { TEST_AUTH_OBJECT } from "../../utils/testing";
import SideMenu from "./SideMenu";

const renderMenu = async () => {
  const { container } = render(
    <UserProvider>
      <BrowserRouter>
        <SideMenu />
      </BrowserRouter>
    </UserProvider>
  );
  await waitFor(() => {});
  return container;
};

describe("SideMenu", () => {
  it("Unauthenticated", async () => {
    setToken(null);
    const container = await renderMenu();
    expect(container).toMatchSnapshot();
  });

  it("Authenticated", async () => {
    setToken(TEST_AUTH_OBJECT);
    const container = await renderMenu();
    expect(container).toMatchSnapshot();
  });
});
