import React from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import Button from '../index';
describe('Button', function () {
  it('renders correctly', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(Button, null, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('theme', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(Button, {
      theme: "primary"
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('block', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(Button, {
      block: true
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('ghost', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(Button, {
      ghost: true
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('size', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(Button, {
      size: "lg"
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('shape is radius', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(Button, {
      shape: "radius"
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('icon', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(Button, {
      icon: /*#__PURE__*/React.createElement("img", {
        alt: "",
        src: "https://zarm.design/images/logo.ce68565d.svg"
      })
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('loading', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(Button, {
      loading: true
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('disabled', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(Button, {
      disabled: true
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('htmlType', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(Button, {
      htmlType: "submit"
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('onClick', function () {
    var onClick = jest.fn();
    render( /*#__PURE__*/React.createElement(Button, {
      onClick: onClick
    }, "button click"));
    var btn = screen.getByText('button click');
    fireEvent.click(btn);
    expect(onClick).toBeCalled();
  });
  it('onClick when disabled', function () {
    var onClick = jest.fn();
    render( /*#__PURE__*/React.createElement("div", {
      "data-testid": "za-btn"
    }, /*#__PURE__*/React.createElement(Button, {
      disabled: true,
      onClick: onClick
    }, "button disable")));
    var btn = screen.getByText('button disable');
    fireEvent.click(btn);
    expect(onClick).not.toBeCalled();
  });
  it('href and target', function () {
    var wrapper = render( /*#__PURE__*/React.createElement(Button, {
      href: "https://zarm.design",
      target: "_blank"
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
});