import { render, screen } from "@testing-library/react";
import { Provider } from "react-redux";
import { Router } from "react-router-dom";
import ColorModeProvider from "../../context/ColorModeContext";
import SelectionProcessOfApplicantPage from "../../pages/SelectionProcessPage/SelectionProcessOfApplicantPage";
import store from "../../store";
import history from "../../store/utils/history";
import * as redux from "react-redux";
import { mockState } from "../../mockState";

describe("applicant selection process details test", () => {
  var cont = (
    <Router history={history}>
      <Provider store={store}>
        <ColorModeProvider>
          <SelectionProcessOfApplicantPage />
        </ColorModeProvider>
      </Provider>
    </Router>
  );

  let spyOnUseSelector;
  let spyOnUseDispatch;
  let mockDispatch;

  beforeEach(() => {
    // Mock useSelector hook
    spyOnUseSelector = jest.spyOn(redux, "useSelector");
    spyOnUseSelector.mockReturnValue(mockState.applSelection);

    // Mock useDispatch hook
    spyOnUseDispatch = jest.spyOn(redux, "useDispatch");

    // Mock dispatch function returned from useDispatch
    mockDispatch = jest.fn();
    spyOnUseDispatch.mockReturnValueOnce(mockDispatch);
  });

  afterEach(() => {
    jest.restoreAllMocks();
  });

  it("should render", () => {
    render(cont);
    expect(screen.getByTestId("appl-sel")).toBeDefined();
  });

//   ?
//   it("should render applicant selection", () => {
//     render(cont);
//     expect(screen.getByTestId("appSelection")).toBeDefined();
//   });
});
