"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.radioUniDriverFactory = 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 _Radio = require("./Radio.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 radioUniDriverFactory = base => {
  var byHook = hook => base.$("[data-hook=\"".concat(hook, "\"]"));
  var getInput = () => byHook(_Radio.dataHooks.input);
  var getIcon = () => byHook(_Radio.dataHooks.icon);
  var getLabel = () => byHook(_Radio.dataHooks.label);
  return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, {
    /**
     * Triggers a keyDown event on the radio input.
     */
    keyDown: key => getInput().pressKey(key),
    /**
     * Gets value of radio input.
     */
    getValue: () => getInput().attr('value'),
    /**
     * Gets name of radio input.
     */
    getName: () => getInput().attr('name'),
    /**
     * Gets id of radio input.
     */
    getId: () => getInput().attr('id'),
    /**
     * Gets label text of radio.
     */
    getLabel: function (_getLabel) {
      function getLabel() {
        return _getLabel.apply(this, arguments);
      }
      getLabel.toString = function () {
        return _getLabel.toString();
      };
      return getLabel;
    }(() => getLabel().text()),
    /**
     * Checks if icon of radio exists.
     */
    iconExists: () => getIcon().exists(),
    /**
     * Checks if label of radio exists.
     */
    labelExists: () => getLabel().exists(),
    /**
     * Checks if radio is checked.
     */
    isChecked: function () {
      var _isChecked = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr('data-checked')) === 'true';
      });
      function isChecked() {
        return _isChecked.apply(this, arguments);
      }
      return isChecked;
    }(),
    /**
     * Checks if radio is disabled.
     */
    isDisabled: function () {
      var _isDisabled = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr('data-disabled')) === 'true';
      });
      function isDisabled() {
        return _isDisabled.apply(this, arguments);
      }
      return isDisabled;
    }(),
    /**
     * Triggers a mouseEnter event.
     */
    mouseEnter: () => base.hover(),
    /**
     * Triggers a mouseLeave event.
     */
    mouseLeave: () => base.mouse.leave()
  });
};
exports.radioUniDriverFactory = radioUniDriverFactory;
//# sourceMappingURL=Radio.uni.driver.js.map