wix-style-react
Version:
73 lines (58 loc) • 3.12 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
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) { _defineProperty(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; }
import { baseUniDriverFactory } from 'wix-ui-test-utils/base-driver';
import { dataHooks } from './constants';
export var radioButtonUniDriverFactory = function radioButtonUniDriverFactory(base, body) {
var getByDataHook = function getByDataHook(dataHook) {
return base.$("[data-hook=\"".concat(dataHook, "\"]"));
};
var radioButtonWrapper = function radioButtonWrapper() {
return getByDataHook(dataHooks.RadioButtonWrapper);
};
var radioButtonInput = function radioButtonInput() {
return getByDataHook(dataHooks.RadioButtonInput);
};
var radioButtonLabel = function radioButtonLabel() {
return getByDataHook(dataHooks.RadioButtonLabel);
};
var radioButtonContent = function radioButtonContent() {
return getByDataHook(dataHooks.RadioButtonContent);
};
return _objectSpread(_objectSpread({}, 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();
}
});
};