wix-style-react
Version:
wix-style-react
47 lines (42 loc) • 1.43 kB
JavaScript
import React from 'react';
import { Simulate, renderIntoDocument } from 'react-dom/test-utils';
import Ticker from '../Ticker';
import styles from '../Ticker.scss';
export var tickerDriverFactory = function tickerDriverFactory(component) {
var handlers = {
getUp: function getUp() {
return component.querySelector('.' + styles.up);
},
getDown: function getDown() {
return component.querySelector('.' + styles.down);
},
clickUp: function clickUp() {
return Simulate.click(handlers.getUp());
},
clickDown: function clickDown() {
return Simulate.click(handlers.getDown());
},
isUpDisabled: function isUpDisabled() {
return handlers.getUp().classList.contains(styles.disabled);
},
isDownDisabled: function isDownDisabled() {
return handlers.getDown().classList.contains(styles.disabled);
},
exists: function exists() {
return !!component;
}
};
return handlers;
};
export var componentFactory = function componentFactory() {
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return renderIntoDocument(React.createElement(
'div',
null,
React.createElement(Ticker, props)
)).childNodes[0];
};
export var tickerTestkitFactory = function tickerTestkitFactory(_ref) {
var wrapper = _ref.wrapper;
return tickerDriverFactory(wrapper.querySelector('[data-hook=ticker]'));
};