UNPKG

wix-style-react

Version:
81 lines (74 loc) 2.39 kB
import { tickerTestkitFactory } from '../Input/Ticker/testkit/Ticker'; import ReactTestUtils from 'react-dom/test-utils'; import { testkitFactoryCreator } from 'wix-ui-test-utils/vanilla'; import inputDriverFactory from '../Input/Input.driver'; import { dataHooks } from './constants'; var inputTestkitFactory = testkitFactoryCreator(inputDriverFactory); var timeInputDriverFactory = function timeInputDriverFactory(_ref) { var element = _ref.element; var input = function input() { return inputTestkitFactory({ wrapper: element, dataHook: dataHooks.input }); }; var inputTicker = function inputTicker() { return tickerTestkitFactory({ wrapper: element }); }; var amPmIndicator = function amPmIndicator() { return element.querySelector("[data-hook=\"".concat(dataHooks.amPmIndicator, "\"]")); }; return { exists: function exists() { return !!element; }, getValue: function getValue() { return input().getValue(); }, isDisabled: function isDisabled() { return input().isDisabled(); }, clickTickerUp: function clickTickerUp() { return inputTicker().clickUp(); }, clickTickerDown: function clickTickerDown() { return inputTicker().clickDown(); }, isAmPmIndicatorExist: function isAmPmIndicatorExist() { return !!amPmIndicator(); }, toggleAmPmIndicator: function toggleAmPmIndicator() { return ReactTestUtils.Simulate.click(amPmIndicator()); }, getAmPmIndicatorText: function getAmPmIndicatorText() { return amPmIndicator().innerHTML; }, getCustomSuffix: function getCustomSuffix() { var customSuffix = element.querySelector("[data-hook=\"".concat(dataHooks.customSuffix, "\"]")); if (customSuffix) { return customSuffix.innerHTML; } }, isRtl: function isRtl() { return input().isRTL(); }, setValue: function setValue(value) { return input().enterText(value); }, blur: function blur() { return input().blur(); }, hasStatus: function hasStatus(status) { return input().hasStatus(status); }, getStatusMessage: function getStatusMessage() { return input().getStatusMessage(); }, isShowSeconds: function isShowSeconds() { return input().getValue().length === 8; } }; }; export default timeInputDriverFactory;