/**
 * 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 {mount} from "enzyme";
import Pill from "../Pill";

describe("Pill", () => {
  it("works as expected, shows close button if onDismiss is provided", () => {
    expect(mount(<Pill onDismiss={() => {}}>child</Pill>)).toMatchSnapshot();
  });

  it("works as expected, does not show close button if onDismiss is not provided", () => {
    expect(mount(<Pill>child</Pill>)).toMatchSnapshot();
  });

  it("handles onDismiss", () => {
    let clicked = false;
    const handleDismiss = () => {
      clicked = true;
    };
    const pill = mount(<Pill onDismiss={handleDismiss}>pill</Pill>);

    pill.find("button").simulate("click");

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