wix-style-react
Version:
86 lines (65 loc) • 3.5 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.radioButtonUniDriverFactory = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _baseDriver = require("wix-ui-test-utils/base-driver");
var _constants = require("./constants");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var radioButtonUniDriverFactory = function radioButtonUniDriverFactory(base, body) {
var getByDataHook = function getByDataHook(dataHook) {
return base.$("[data-hook=\"".concat(dataHook, "\"]"));
};
var radioButtonWrapper = function radioButtonWrapper() {
return getByDataHook(_constants.dataHooks.RadioButtonWrapper);
};
var radioButtonInput = function radioButtonInput() {
return getByDataHook(_constants.dataHooks.RadioButtonInput);
};
var radioButtonLabel = function radioButtonLabel() {
return getByDataHook(_constants.dataHooks.RadioButtonLabel);
};
var radioButtonContent = function radioButtonContent() {
return getByDataHook(_constants.dataHooks.RadioButtonContent);
};
return _objectSpread(_objectSpread({}, (0, _baseDriver.baseUniDriverFactory)(base, body)), {}, {
/** Simulating a check action by clicking the input element */
check: function check() {
return radioButtonInput().click();
},
/** Getting the component's "checked" value */
isChecked: function isChecked() {
return radioButtonInput()._prop('checked');
},
/** Getting the component's "disabled" value */
isDisabled: function isDisabled() {
return radioButtonInput()._prop('disabled');
},
/** Getting the component's label text value */
getLabel: function getLabel() {
return radioButtonLabel().text();
},
/** Getting the component's label element */
// eslint-disable-next-line no-restricted-properties
getLabelElement: function getLabelElement() {
return radioButtonLabel().getNative();
},
/** Getting the component's input value */
getValue: function getValue() {
return radioButtonInput()._prop('value');
},
/** Getting the component's tab-index value */
getTabIndex: function getTabIndex() {
return radioButtonWrapper().attr('tabIndex');
},
/** Getting the component's content element */
// eslint-disable-next-line no-restricted-properties
getContent: function getContent() {
return radioButtonContent().getNative();
}
});
};
exports.radioButtonUniDriverFactory = radioButtonUniDriverFactory;