{"size": 1085, "ext": "js", "max_stars_repo_path": "src/containers/CourseListPage/components/SelectModeSwitch/SelectModeSwitch.test.js", "max_stars_repo_name": "martinpham97/abacus-omega", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/containers/CourseListPage/components/SelectModeSwitch/SelectModeSwitch.test.js", "max_issues_repo_name": "martinpham97/abacus-omega", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/containers/CourseListPage/components/SelectModeSwitch/SelectModeSwitch.test.js", "max_forks_repo_name": "martinpham97/abacus-omega", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.8333333333, "max_line_length": 79, "alphanum_fraction": 0.6728110599}
import { render, screen, fireEvent } from "@testing-library/react";
import { axe } from "jest-axe";

import SelectModeSwitch from "./SelectModeSwitch";

describe("<SelectModeSwitch />", () => {
  let mockHandleToggleSelectMode;

  beforeEach(() => {
    mockHandleToggleSelectMode = jest.fn();
  });

  it("should call handleToggleSelectMode on click", () => {
    render(
      <SelectModeSwitch handleToggleSelectMode={mockHandleToggleSelectMode} />,
    );

    fireEvent.click(screen.getByRole("checkbox"));

    expect(mockHandleToggleSelectMode).toHaveBeenCalled();
  });

  it("should handle switch checked state with selectMode prop", () => {
    render(
      <SelectModeSwitch
        selectMode
        handleToggleSelectMode={mockHandleToggleSelectMode}
      />,
    );

    expect(screen.getByRole("checkbox").checked).toEqual(true);
  });

  it("should be accessible", async () => {
    const { container } = render(
      <SelectModeSwitch handleToggleSelectMode={mockHandleToggleSelectMode} />,
    );

    expect(await axe(container)).toHaveNoViolations();
  });
});
