"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.floatingNotificationDriverFactory = void 0;
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
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 floatingNotificationDriverFactory = base => {
  var getByDataHook = dataHook => base.$("[data-hook=\"".concat(dataHook, "\"]"));
  var notificationButton = getByDataHook(_constants.dataHooks.button);
  var notificationTextButton = getByDataHook(_constants.dataHooks.textButton);
  var notificationCloseButton = getByDataHook(_constants.dataHooks.closeButton);
  var notificationText = getByDataHook(_constants.dataHooks.notificationText);
  return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, {
    /**
     * Clicks notification button.
     */
    clickButton: function () {
      var _clickButton = (0, _asyncToGenerator2.default)(function* () {
        return notificationButton.click();
      });
      function clickButton() {
        return _clickButton.apply(this, arguments);
      }
      return clickButton;
    }(),
    /**
     * Get the notification button's text.
     */
    getButtonLabel: function () {
      var _getButtonLabel = (0, _asyncToGenerator2.default)(function* () {
        return notificationButton.text();
      });
      function getButtonLabel() {
        return _getButtonLabel.apply(this, arguments);
      }
      return getButtonLabel;
    }(),
    /**
     * Clicks the notification text button.
     */
    clickTextButton: function () {
      var _clickTextButton = (0, _asyncToGenerator2.default)(function* () {
        return notificationTextButton.click();
      });
      function clickTextButton() {
        return _clickTextButton.apply(this, arguments);
      }
      return clickTextButton;
    }(),
    /**
     * Get the notification text button's text
     */
    getTextButtonLabel: function () {
      var _getTextButtonLabel = (0, _asyncToGenerator2.default)(function* () {
        return notificationTextButton.text();
      });
      function getTextButtonLabel() {
        return _getTextButtonLabel.apply(this, arguments);
      }
      return getTextButtonLabel;
    }(),
    /** Clicks the notification close button
     */
    clickCloseButton: function () {
      var _clickCloseButton = (0, _asyncToGenerator2.default)(function* () {
        return notificationCloseButton.click();
      });
      function clickCloseButton() {
        return _clickCloseButton.apply(this, arguments);
      }
      return clickCloseButton;
    }(),
    /**
     * Get the notification text.
     */
    getText: function () {
      var _getText = (0, _asyncToGenerator2.default)(function* () {
        return notificationText.text();
      });
      function getText() {
        return _getText.apply(this, arguments);
      }
      return getText;
    }(),
    /**
     * Checks whether button with passed tag name exists.
     * @param as Tag name
     */
    isButtonAs: function () {
      var _isButtonAs = (0, _asyncToGenerator2.default)(function* (as) {
        return yield base.$("".concat(as, "[data-hook=\"").concat(_constants.dataHooks.button, "\"]")).exists();
      });
      function isButtonAs(_x) {
        return _isButtonAs.apply(this, arguments);
      }
      return isButtonAs;
    }(),
    /**
     * Get the notification button href attribute's value.
     */
    getButtonHref: function () {
      var _getButtonHref = (0, _asyncToGenerator2.default)(function* () {
        return notificationButton.attr('href');
      });
      function getButtonHref() {
        return _getButtonHref.apply(this, arguments);
      }
      return getButtonHref;
    }(),
    /**
     * Get the notification button attribute's value by name.
     * @param attrName Attribute name
     */
    getButtonAttr: function () {
      var _getButtonAttr = (0, _asyncToGenerator2.default)(function* (attrName) {
        return notificationButton.attr(attrName);
      });
      function getButtonAttr(_x2) {
        return _getButtonAttr.apply(this, arguments);
      }
      return getButtonAttr;
    }(),
    /**
     * Checks whether text button with passed tag name exists.
     * @param as Tag name
     */
    isTextButtonAs: function () {
      var _isTextButtonAs = (0, _asyncToGenerator2.default)(function* (as) {
        return yield base.$("".concat(as, "[data-hook=\"").concat(_constants.dataHooks.textButton, "\"]")).exists();
      });
      function isTextButtonAs(_x3) {
        return _isTextButtonAs.apply(this, arguments);
      }
      return isTextButtonAs;
    }(),
    /**
     * Get the notification text button href attribute's value.
     */
    getTextButtonHref: function () {
      var _getTextButtonHref = (0, _asyncToGenerator2.default)(function* () {
        return notificationTextButton.attr('href');
      });
      function getTextButtonHref() {
        return _getTextButtonHref.apply(this, arguments);
      }
      return getTextButtonHref;
    }(),
    /**
     * Get the notification text button attribute's value by name.
     * @param  attrName Attribute name
     */
    getTextButtonAttr: function () {
      var _getTextButtonAttr = (0, _asyncToGenerator2.default)(function* (attrName) {
        return notificationTextButton.attr(attrName);
      });
      function getTextButtonAttr(_x4) {
        return _getTextButtonAttr.apply(this, arguments);
      }
      return getTextButtonAttr;
    }()
  });
};
exports.floatingNotificationDriverFactory = floatingNotificationDriverFactory;
//# sourceMappingURL=FloatingNotification.uni.driver.js.map