"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _react = _interopRequireDefault(require("react"));

var _react2 = require("@testing-library/react");

var _index = _interopRequireDefault(require("../index"));

describe('Button', function () {
  it('renders correctly', function () {
    var wrapper = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, null, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('theme', function () {
    var wrapper = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      theme: "primary"
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('block', function () {
    var wrapper = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      block: true
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('ghost', function () {
    var wrapper = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      ghost: true
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('size', function () {
    var wrapper = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      size: "lg"
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('shape is radius', function () {
    var wrapper = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      shape: "radius"
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('icon', function () {
    var wrapper = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      icon: /*#__PURE__*/_react.default.createElement("img", {
        alt: "",
        src: "https://zarm.design/images/logo.ce68565d.svg"
      })
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('loading', function () {
    var wrapper = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      loading: true
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('disabled', function () {
    var wrapper = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      disabled: true
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('htmlType', function () {
    var wrapper = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      htmlType: "submit"
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
  it('onClick', function () {
    var onClick = jest.fn();
    (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      onClick: onClick
    }, "button click"));

    var btn = _react2.screen.getByText('button click');

    _react2.fireEvent.click(btn);

    expect(onClick).toBeCalled();
  });
  it('onClick when disabled', function () {
    var onClick = jest.fn();
    (0, _react2.render)( /*#__PURE__*/_react.default.createElement("div", {
      "data-testid": "za-btn"
    }, /*#__PURE__*/_react.default.createElement(_index.default, {
      disabled: true,
      onClick: onClick
    }, "button disable")));

    var btn = _react2.screen.getByText('button disable');

    _react2.fireEvent.click(btn);

    expect(onClick).not.toBeCalled();
  });
  it('href and target', function () {
    var wrapper = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.default, {
      href: "https://zarm.design",
      target: "_blank"
    }, "foo"));
    expect(wrapper.asFragment()).toMatchSnapshot();
  });
});