wix-style-react
Version:
82 lines (63 loc) • 2.3 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));
var _constants = require("./constants");
var radioButtonDriverFactory = function radioButtonDriverFactory(_ref) {
var element = _ref.element;
var getByDataHook = function getByDataHook(dataHook) {
return element.querySelector("[data-hook=\"".concat(dataHook, "\"]"));
};
var radioWrapper = function radioWrapper() {
return getByDataHook(_constants.dataHooks.RadioButtonWrapper);
};
var radioButton = function radioButton() {
return getByDataHook(_constants.dataHooks.RadioButtonInput);
};
var label = function label() {
return getByDataHook(_constants.dataHooks.RadioButtonLabel);
};
return {
/** Simulating a check action by clicking the input element */
exists: function exists() {
return !!element;
},
/** Simulating a check action by clicking the input element */
check: function check() {
return _testUtils["default"].Simulate.change(radioButton());
},
/** Getting the component's "checked" value */
isChecked: function isChecked() {
return radioButton().checked;
},
/** Getting the component's "disabled" value */
isDisabled: function isDisabled() {
return radioButton().disabled;
},
/** Getting the component's label text value */
getLabel: function getLabel() {
return label().textContent;
},
/** Getting the component's label element */
getLabelElement: function getLabelElement() {
return label();
},
/** Getting the component's input value */
getValue: function getValue() {
return radioButton().value;
},
/** Getting the component's tab-index value */
getTabIndex: function getTabIndex() {
return radioWrapper().getAttribute('tabIndex');
},
/** Getting the component's content element */
getContent: function getContent() {
return element.querySelector("[data-hook=\"".concat(_constants.dataHooks.RadioButtonContent, "\"]"));
}
};
};
var _default = radioButtonDriverFactory;
exports["default"] = _default;