/**
 * TEAM: frontend_infra
 *
 * @flow
 */

// TODO: Fix this eslint issue on next edit. This is an autogenerated comment.
// eslint-disable-next-line flexport/no-legacy-dependencies
import {shallow} from "enzyme";

import ToggleButton from "../ToggleButton";

describe("ToggleButton", () => {
  it("renders", () => {
    const component = <ToggleButton iconName="cog" label="test" />;
    expect(component).toMatchSnapshot();
  });

  it("should show toggle icon by default", () => {
    const component = <ToggleButton label="test" hideToggleIcon={false} />;
    const wrapper = shallow(component);

    expect(wrapper.props().children.filter(child => !!child).length).toBe(2);
  });

  it("should not show toggle icon when hideToggleIcon is set to true", () => {
    const component = <ToggleButton label="test" hideToggleIcon={true} />;
    const wrapper = shallow(component);

    expect(wrapper.props().children.filter(child => !!child).length).toBe(1);
  });
});
