{"size": 1555, "ext": "js", "max_stars_repo_path": "src/components/ControlPanel.test.js", "max_stars_repo_name": "ianjmacintosh/pozo", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/ControlPanel.test.js", "max_issues_repo_name": "ianjmacintosh/pozo", "max_issues_repo_issues_event_min_datetime": "2018-09-29T15:46:26.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-13T17:04:52.000Z", "max_forks_repo_path": "src/components/ControlPanel.test.js", "max_forks_repo_name": "ianjmacintosh/pozo", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 117, "max_forks_count": null, "avg_line_length": 25.0806451613, "max_line_length": 69, "alphanum_fraction": 0.6257234727}
import React from "react";
import { render, fireEvent, screen } from "@testing-library/react";

import ControlPanel from "./ControlPanel";

describe("ControlPanel", () => {
  // Arrange
  render(<ControlPanel />);

  describe("sound effects toggle button", () => {
    it("exists", () => {
      // Act
      let sfxToggleButton = screen.getByTestId("mute-toggleSfx");

      // Assert
      expect(sfxToggleButton).toBeInTheDocument();
    });

    it("calls when toggleSfxMute when clicked", () => {
      // Arrange Enzyme test
      const mockedToggleSfxMute = jest.fn();
      const mockedToggleMusicMute = jest.fn();
      render(
        <ControlPanel
          toggleSfxMute={mockedToggleSfxMute}
          toggleMusicMute={mockedToggleMusicMute}
        />
      );

      let sfxToggleButton = screen.getByTestId("mute-toggleSfx");

      // Act
      // Click on sfx toggle button
      fireEvent.click(sfxToggleButton);

      // Assert
      // Confirm toggleMusicMute was called
      expect(mockedToggleSfxMute).toHaveBeenCalledTimes(1);
    });
  });

  it("has a sound effects toggle button", () => {
    // Arrange
    render(<ControlPanel />);
    // Act
    const sfxToggleButton = screen.getByTestId("mute-toggleSfx");

    // Assert
    expect(sfxToggleButton).toBeInTheDocument();
  });

  it("has a music toggle button", () => {
    // Arrange
    render(<ControlPanel />);
    // Act
    const musicToggleButton = screen.getByTestId("mute-toggleMusic");

    // Assert
    expect(musicToggleButton).toBeInTheDocument();
  });
});
