wix-style-react
Version:
wix-style-react
48 lines (42 loc) • 1.78 kB
JavaScript
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
import dropdownLayoutDriverFactory from '../DropdownLayout/DropdownLayout.driver';
import ReactTestUtils from 'react-dom/test-utils';
import { isClassExists } from '../../test/utils';
var IconWithOptionsDriverFactory = function IconWithOptionsDriverFactory(_ref) {
var _element = _ref.element;
var _iconWrapper = _element.querySelector('[data-hook=icon-wrapper]');
var dropdownLayoutWrapper = _element.querySelector('[data-hook=iconWithOptions-dropdownLayout-wrapper]');
var dropdownLayout = _element.querySelector('[data-hook=iconWithOptions-dropdownLayout]');
var dropdownLayoutDriver = dropdownLayoutDriverFactory({
element: dropdownLayout
});
var driver = {
exists: function exists() {
return !!_element;
},
mouseEnter: function mouseEnter() {
return ReactTestUtils.Simulate.mouseEnter(_iconWrapper);
},
mouseLeave: function mouseLeave() {
return ReactTestUtils.Simulate.mouseLeave(_element);
},
isIconBlue: function isIconBlue() {
return isClassExists(_element, 'hover');
},
iconWrapper: function iconWrapper() {
return _iconWrapper;
},
element: function element() {
return _element;
}
};
return {
driver: driver,
dropdownLayoutDriver: _extends({}, dropdownLayoutDriver, {
isDropDirectionUp: function isDropDirectionUp() {
return dropdownLayoutDriver.isUp() && isClassExists(dropdownLayoutWrapper, 'dropDirectionUp');
}
})
};
};
export default IconWithOptionsDriverFactory;