wix-style-react
Version:
wix-style-react
58 lines (50 loc) • 1.99 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _testUtils = require('react-dom/test-utils');
var _testUtils2 = _interopRequireDefault(_testUtils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var fieldWithSelectionCompositeDriverFactory = function fieldWithSelectionCompositeDriverFactory(_ref) {
var element = _ref.element;
var label = element.querySelector('.label>label');
var textInput = element.querySelector('input.input') || element.querySelector('textarea');
var deprecatedSelectionInput = element.querySelector('input');
return {
exists: function exists() {
return !!element;
},
getLabel: function getLabel() {
return label && label.textContent;
},
/** @deprecated it is for internal testing and should not be exposed to users */
hasLabel: function hasLabel() {
return !!label;
},
/** @deprecated it is for internal testing and should not be exposed to users */
hasInput: function hasInput() {
return !!textInput;
},
getInput: function getInput() {
return textInput;
},
triggerInputBlur: function triggerInputBlur() {
return _testUtils2.default.Simulate.blur(textInput);
},
/** @deprecated it is for internal testing and should not be exposed to users */
hasSelectionInput: function hasSelectionInput() {
return !!deprecatedSelectionInput.tagName;
},
getAttr: function getAttr(attrName) {
return element.getAttribute(attrName);
},
/** @deprecated it is for internal testing and should not be exposed to users */
getNumberOfChildren: function getNumberOfChildren() {
return element.childElementCount;
},
hasFieldLabelAttributes: function hasFieldLabelAttributes() {
return !!element.querySelectorAll('[data-hook="field-label-attributes"]').length;
}
};
};
exports.default = fieldWithSelectionCompositeDriverFactory;