import * as redux from "react-redux";
import store from "../../store";
import { Router } from "react-router-dom";
import { render } from "@testing-library/react";
import history from "../../store/utils/history";
import ErrorPage from "../../pages/ErrorPages/ErrorPage";

describe("ErrorPage render tests", () => {
  const cont = (
    <redux.Provider store={store}>
      <Router history={history}>
        <ErrorPage />
      </Router>
    </redux.Provider>
  );

  // beforeEach(() => {
  //   jest.mock("react-i18next", () => ({
  //     useTranslation: () => ({
  //       t: (key) => key,
  //       i18n: { changeLanguage: jest.fn() },
  //     }),
  //   }));
  // });

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

  it("Should render", () => {
    const { container } = render(cont);
    expect(container.getElementsByClassName("c-error-page")[0]).toBeDefined();
  });

  it("Should render status code 500", () => {
    const { container } = render(cont);
    expect(
      container.getElementsByClassName("c-error-page__title")[0].textContent
    ).toBe("500");
  });

  it("Should render text", () => {
    const { container } = render(cont);
    expect(
      container.getElementsByClassName("c-error-page__text")[0]
    ).toBeDefined();
  });
});
