UNPKG

wix-style-react

Version:
45 lines 1.8 kB
import _extends from "@babel/runtime/helpers/extends"; import React from 'react'; import { Simulate, renderIntoDocument } from 'react-dom/test-utils'; import Ticker from '..'; import { InputContext } from '../../InputContext'; import { dataHooks } from '../constants'; export var tickerDriverFactory = function tickerDriverFactory(component) { var handlers = { getUp: function getUp() { return component.querySelector("[data-hook=\"".concat(dataHooks.tickerUp, "\"]")); }, getDown: function getDown() { return component.querySelector("[data-hook=\"".concat(dataHooks.tickerDown, "\"]")); }, clickUp: function clickUp() { return Simulate.click(handlers.getUp()); }, clickDown: function clickDown() { return Simulate.click(handlers.getDown()); }, isUpDisabled: function isUpDisabled() { return handlers.getUp().hasAttribute('data-disabled'); }, isDownDisabled: function isDownDisabled() { return handlers.getDown().hasAttribute('data-disabled'); }, exists: function exists() { return !!component; } }; return handlers; }; export var componentFactory = function componentFactory() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return renderIntoDocument( /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(InputContext.Provider, { value: context }, /*#__PURE__*/React.createElement(Ticker, _extends({ dataHook: "ticker" }, props))))).childNodes[0]; }; export var tickerTestkitFactory = function tickerTestkitFactory(_ref) { var wrapper = _ref.wrapper; return tickerDriverFactory(wrapper.querySelector('[data-hook=ticker]')); };