"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireDefault(require("react"));
var _CircularProgressBar = _interopRequireDefault(require("../CircularProgressBar"));
var _react2 = require("../../utils/test-utils/react");
var _constants = require("../constants");
var _CircularProgressBarUni = require("../CircularProgressBar.uni.driver");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/CircularProgressBar/test/CircularProgressBar.spec.jsx",
  _this = void 0;
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var createCircularProgressBar = function createCircularProgressBar() {
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  var dataHook = 'circular-progress-bar';
  return /*#__PURE__*/_react["default"].createElement(_CircularProgressBar["default"], (0, _extends2["default"])({}, props, {
    dataHook: dataHook,
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 13,
      columnNumber: 10
    }
  }));
};
describe('CircularProgressBar', function () {
  var defaultProps = {
    value: 40
  };
  describe('[async]', function () {
    runTests((0, _react2.createRendererWithUniDriver)(_CircularProgressBarUni.circularProgressBarDriverFactory));
  });
  function runTests(render) {
    afterEach(function () {
      return (0, _react2.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(createCircularProgressBar(_objectSpread({}, defaultProps))), 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('on error', function () {
      var errorProps = {
        error: true,
        errorMessage: 'No soup for you',
        showProgressIndication: true
      };
      it('should display error message', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
        var _render2, driver, toolTipErrorMsg;
        return _regenerator["default"].wrap(function _callee2$(_context2) {
          while (1) switch (_context2.prev = _context2.next) {
            case 0:
              _render2 = render(createCircularProgressBar(_objectSpread(_objectSpread({}, defaultProps), errorProps))), driver = _render2.driver;
              _context2.next = 3;
              return driver.getTooltipErrorMessage();
            case 3:
              toolTipErrorMsg = _context2.sent;
              expect(toolTipErrorMsg).toEqual(errorProps.errorMessage);
            case 5:
            case "end":
              return _context2.stop();
          }
        }, _callee2);
      })));
      it('should display error 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(createCircularProgressBar(_objectSpread(_objectSpread({}, defaultProps), errorProps))), driver = _render3.driver;
              _context3.t0 = expect;
              _context3.next = 4;
              return driver.isErrorIconShown();
            case 4:
              _context3.t1 = _context3.sent;
              (0, _context3.t0)(_context3.t1).toBe(true);
            case 6:
            case "end":
              return _context3.stop();
          }
        }, _callee3);
      })));
    });
    describe('on completion', function () {
      var successProps = {
        value: 100,
        showProgressIndication: true
      };
      it('should display success icon', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4() {
        var _render4, driver;
        return _regenerator["default"].wrap(function _callee4$(_context4) {
          while (1) switch (_context4.prev = _context4.next) {
            case 0:
              _render4 = render(createCircularProgressBar(_objectSpread({}, successProps))), driver = _render4.driver;
              _context4.t0 = expect;
              _context4.next = 4;
              return driver.isSuccessIconShown();
            case 4:
              _context4.t1 = _context4.sent;
              (0, _context4.t0)(_context4.t1).toBe(true);
            case 6:
            case "end":
              return _context4.stop();
          }
        }, _callee4);
      })));
    });
    describe('size prop', function () {
      Object.keys(_constants.Size).forEach(function (size) {
        it("should be ".concat(size), /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5() {
          var _render5, driver;
          return _regenerator["default"].wrap(function _callee5$(_context5) {
            while (1) switch (_context5.prev = _context5.next) {
              case 0:
                _render5 = render(createCircularProgressBar(_objectSpread(_objectSpread({}, defaultProps), {}, {
                  size: size
                }))), driver = _render5.driver;
                _context5.t0 = expect;
                _context5.next = 4;
                return driver.getSize();
              case 4:
                _context5.t1 = _context5.sent;
                (0, _context5.t0)(_context5.t1).toBe(size);
              case 6:
              case "end":
                return _context5.stop();
            }
          }, _callee5);
        })));
      });
      it("should be default ".concat(_constants.Size.medium), /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6() {
        var _render6, driver;
        return _regenerator["default"].wrap(function _callee6$(_context6) {
          while (1) switch (_context6.prev = _context6.next) {
            case 0:
              _render6 = render(createCircularProgressBar(_objectSpread({}, defaultProps))), driver = _render6.driver;
              _context6.t0 = expect;
              _context6.next = 4;
              return driver.getSize();
            case 4:
              _context6.t1 = _context6.sent;
              (0, _context6.t0)(_context6.t1).toBe(_constants.Size.medium);
            case 6:
            case "end":
              return _context6.stop();
          }
        }, _callee6);
      })));
    });
    describe('skin prop', function () {
      Object.keys(_constants.Skin).forEach(function (skin) {
        it("should be ".concat(skin), /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7() {
          var _render7, driver;
          return _regenerator["default"].wrap(function _callee7$(_context7) {
            while (1) switch (_context7.prev = _context7.next) {
              case 0:
                _render7 = render(createCircularProgressBar(_objectSpread(_objectSpread({}, defaultProps), {}, {
                  skin: skin
                }))), driver = _render7.driver;
                _context7.t0 = expect;
                _context7.next = 4;
                return driver.hasSkin(skin);
              case 4:
                _context7.t1 = _context7.sent;
                (0, _context7.t0)(_context7.t1).toBeTruthy();
              case 6:
              case "end":
                return _context7.stop();
            }
          }, _callee7);
        })));
      });
      it("should be default ".concat(_constants.Skin.standard), /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee8() {
        var _render8, driver;
        return _regenerator["default"].wrap(function _callee8$(_context8) {
          while (1) switch (_context8.prev = _context8.next) {
            case 0:
              _render8 = render(createCircularProgressBar(_objectSpread({}, defaultProps))), driver = _render8.driver;
              _context8.t0 = expect;
              _context8.next = 4;
              return driver.hasSkin(_constants.Skin.standard);
            case 4:
              _context8.t1 = _context8.sent;
              (0, _context8.t0)(_context8.t1).toBeTruthy();
            case 6:
            case "end":
              return _context8.stop();
          }
        }, _callee8);
      })));
    });
  }
});