import * as redux from "react-redux";
import store from "../../store";
import { Router } from "react-router-dom";
import { mockState } from "../../mockState";
import { render } from "@testing-library/react";
import DayComponent from "../../components/Schedules/DayComponent";
import history from "../../store/utils/history";

const props = {
  numberOfDay: 1,
  nameOfDay: "sre",
  interviews: mockState.schedule.schedule,
  onClick: jest.fn(),
};

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

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

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

  it("Should show only two interviews even if there is more interviews and span element which will tell us how many interviews is there", () => {
    const { container } = render(cont);
    expect(
      container.getElementsByClassName("day-component-more")[0]
    ).toBeDefined();
    expect(
      container.getElementsByClassName("day-component-interviews-container")
        .length
    ).toBe(2);
  });
});
