{"size": 618, "ext": "js", "max_stars_repo_path": "package/src/index.test.js", "max_stars_repo_name": "brunoscopelliti/use-toggle", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "package/src/index.test.js", "max_issues_repo_name": "brunoscopelliti/use-toggle", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "package/src/index.test.js", "max_forks_repo_name": "brunoscopelliti/use-toggle", "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": 18.7272727273, "max_line_length": 63, "alphanum_fraction": 0.5631067961}
import { renderHook, act } from "@testing-library/react-hooks";
import useToggle from "./";

describe("useToggle", () => {
  it("returns `false` as default state", () => {
    const { result } = renderHook(() => useToggle());

    const [state] = result.current;

    expect(state).toBe(false);
  });

  it("returns the state, and the handler to change it", () => {
    let state, toggle;

    renderHook(
      () => {
        [state, toggle] = useToggle(true);
      }
    );

    expect(state).toBe(true);

    act(toggle);

    expect(state).toBe(false);

    act(toggle);

    expect(state).toBe(true);
  });
});
