"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _react = _interopRequireDefault(require("react"));
var _unit = require("../../utils/test-utils/unit");
var _FillButton = _interopRequireDefault(require("../FillButton"));
var _FillButtonPrivateUni = require("./FillButton.private.uni.driver");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/FillButton/test/FillButton.spec.jsx",
  _this = void 0;
describe('FillButton', function () {
  var render = (0, _unit.createRendererWithUniDriver)(_FillButtonPrivateUni.fillButtonPrivateDriverFactory);
  afterEach(function () {
    (0, _unit.cleanup)();
  });
  it('should render', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
    var _render, driver;
    return _regenerator["default"].wrap(function _callee$(_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          _render = render(/*#__PURE__*/_react["default"].createElement(_FillButton["default"], {
            __self: _this,
            __source: {
              fileName: _jsxFileName,
              lineNumber: 18,
              columnNumber: 31
            }
          })), driver = _render.driver;
          _context.t0 = expect;
          _context.next = 4;
          return driver.exists();
        case 4:
          _context.t1 = _context.sent;
          (0, _context.t0)(_context.t1).toBe(true);
        case 6:
        case "end":
          return _context.stop();
      }
    }, _callee);
  })));
  describe('`iconSize` prop', function () {
    it('[when] given small should render small icon', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
      var _render2, driver;
      return _regenerator["default"].wrap(function _callee2$(_context2) {
        while (1) switch (_context2.prev = _context2.next) {
          case 0:
            _render2 = render(/*#__PURE__*/_react["default"].createElement(_FillButton["default"], {
              iconSize: "small",
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 24,
                columnNumber: 33
              }
            })), driver = _render2.driver;
            _context2.t0 = expect;
            _context2.next = 4;
            return driver.isIconSmall();
          case 4:
            _context2.t1 = _context2.sent;
            (0, _context2.t0)(_context2.t1).toBe(true);
          case 6:
          case "end":
            return _context2.stop();
        }
      }, _callee2);
    })));
    it('[when] given medium should render medium icon', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() {
      var _render3, driver;
      return _regenerator["default"].wrap(function _callee3$(_context3) {
        while (1) switch (_context3.prev = _context3.next) {
          case 0:
            _render3 = render(/*#__PURE__*/_react["default"].createElement(_FillButton["default"], {
              iconSize: "medium",
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 29,
                columnNumber: 33
              }
            })), driver = _render3.driver;
            _context3.t0 = expect;
            _context3.next = 4;
            return driver.isIconMedium();
          case 4:
            _context3.t1 = _context3.sent;
            (0, _context3.t0)(_context3.t1).toBe(true);
          case 6:
          case "end":
            return _context3.stop();
        }
      }, _callee3);
    })));
  });
  describe('`onClick` prop', function () {
    it('[when] given should be called when clicked', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4() {
      var onClick, _render4, driver;
      return _regenerator["default"].wrap(function _callee4$(_context4) {
        while (1) switch (_context4.prev = _context4.next) {
          case 0:
            onClick = vi.fn();
            _render4 = render(/*#__PURE__*/_react["default"].createElement(_FillButton["default"], {
              onClick: onClick,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 37,
                columnNumber: 33
              }
            })), driver = _render4.driver;
            _context4.next = 4;
            return driver.click();
          case 4:
            expect(onClick).toHaveBeenCalled();
          case 5:
          case "end":
            return _context4.stop();
        }
      }, _callee4);
    })));
  });
  describe('`tooltipProps` prop', function () {
    it('[when] given should pass textual content to tooltip', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5() {
      var tooltipContent, _render5, driver;
      return _regenerator["default"].wrap(function _callee5$(_context5) {
        while (1) switch (_context5.prev = _context5.next) {
          case 0:
            tooltipContent = 'hello';
            _render5 = render(/*#__PURE__*/_react["default"].createElement(_FillButton["default"], {
              tooltipContent: tooltipContent,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 46,
                columnNumber: 33
              }
            })), driver = _render5.driver;
            _context5.t0 = expect;
            _context5.next = 5;
            return driver.getTooltipText();
          case 5:
            _context5.t1 = _context5.sent;
            (0, _context5.t0)(_context5.t1).toBe(tooltipContent);
          case 7:
          case "end":
            return _context5.stop();
        }
      }, _callee5);
    })));
  });
  it('should not submit form on click', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6() {
    var onSubmit, onClick, _render6, driver;
    return _regenerator["default"].wrap(function _callee6$(_context6) {
      while (1) switch (_context6.prev = _context6.next) {
        case 0:
          onSubmit = vi.fn();
          onClick = vi.fn();
          _render6 = render(/*#__PURE__*/_react["default"].createElement("form", {
            onSubmit: onSubmit,
            __self: _this,
            __source: {
              fileName: _jsxFileName,
              lineNumber: 56,
              columnNumber: 7
            }
          }, /*#__PURE__*/_react["default"].createElement(_FillButton["default"], {
            onClick: onClick,
            __self: _this,
            __source: {
              fileName: _jsxFileName,
              lineNumber: 57,
              columnNumber: 9
            }
          }))), driver = _render6.driver;
          _context6.next = 5;
          return driver.click();
        case 5:
          expect(onClick).toHaveBeenCalled();
          expect(onSubmit).not.toHaveBeenCalled();
        case 7:
        case "end":
          return _context6.stop();
      }
    }, _callee6);
  })));
});