"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.circularProgressBarCoreUniDriverFactory = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _unidriver = require("../../utils/test-utils/unidriver");
var _constants = require("./constants");
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 byDataHook = dataHook => "[data-hook=\"".concat(dataHook, "\"]");
var circularProgressBarCoreUniDriverFactory = base => {
  var getValue = /*#__PURE__*/function () {
    var _ref = (0, _asyncToGenerator2.default)(function* () {
      if (!(yield base.exists())) {
        return null;
      }
      return base.$(byDataHook(_constants.dataHooks.progressIndicator)).text();
    });
    return function getValue() {
      return _ref.apply(this, arguments);
    };
  }();
  return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, {
    isSuccessIconDisplayed: () => base.$(byDataHook(_constants.dataHooks.successIcon)).exists(),
    isErrorIconDisplayed: () => base.$(byDataHook(_constants.dataHooks.errorIcon)).exists(),
    isLabelDisplayed: () => base.$(byDataHook(_constants.dataHooks.label)).exists(),
    getLabelTextContent: () => base.$(byDataHook(_constants.dataHooks.label)).text(),
    isPercentagesProgressDisplayed: () => base.$(byDataHook(_constants.dataHooks.progressIndicator)).exists(),
    getValue: function (_getValue) {
      function getValue() {
        return _getValue.apply(this, arguments);
      }
      getValue.toString = function () {
        return _getValue.toString();
      };
      return getValue;
    }(() => getValue()),
    isCompleted: function () {
      var _isCompleted = (0, _asyncToGenerator2.default)(function* () {
        return (yield getValue()) === '100';
      });
      function isCompleted() {
        return _isCompleted.apply(this, arguments);
      }
      return isCompleted;
    }(),
    hasError: function () {
      var _hasError = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr('data-error')) === 'true';
      });
      function hasError() {
        return _hasError.apply(this, arguments);
      }
      return hasError;
    }(),
    getAttribute: function () {
      var _getAttribute = (0, _asyncToGenerator2.default)(function* (name) {
        return base.attr(name);
      });
      function getAttribute(_x) {
        return _getAttribute.apply(this, arguments);
      }
      return getAttribute;
    }(),
    isSingleElementRendered: function () {
      var _isSingleElementRendered = (0, _asyncToGenerator2.default)(function* (dataHook) {
        return (yield base.$$(byDataHook(dataHook)).count()) === 1;
      });
      function isSingleElementRendered(_x2) {
        return _isSingleElementRendered.apply(this, arguments);
      }
      return isSingleElementRendered;
    }()
  });
};
exports.circularProgressBarCoreUniDriverFactory = circularProgressBarCoreUniDriverFactory;
//# sourceMappingURL=CircularProgressBarCore.uni.driver.js.map