wix-style-react
Version:
wix-style-react
34 lines (29 loc) • 1.33 kB
JavaScript
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { INTERNAL_DRIVER_SYMBOL } from '../../../test/utils/private-drivers';
import { hasAttribute, isFocused as _isFocused } from '../../../test/utils/protractor-helpers';
var focusableDriverFactory = function focusableDriverFactory(_ref) {
var rootElement = _ref.rootElement,
clickableElements = _ref.clickableElements,
nativeFocusableElement = _ref.nativeFocusableElement;
if (!rootElement || !clickableElements || !nativeFocusableElement) {
throw new Error('focusableDriverFactory: Invalid aruments');
}
return _defineProperty({
isFocused: function isFocused() {
return _isFocused(nativeFocusableElement);
}
}, INTERNAL_DRIVER_SYMBOL, {
rootElement: rootElement,
hasFocusState: function hasFocusState() {
return hasAttribute(rootElement, 'data-focus');
},
hasFocusVisibleState: function hasFocusVisibleState() {
return hasAttribute(rootElement, 'data-focus-visible');
},
clickRoot: function clickRoot() {
return rootElement.click();
},
clickableElements: clickableElements
});
};
export default focusableDriverFactory;