UNPKG

wix-style-react

Version:
346 lines (296 loc) • 10.8 kB
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _regeneratorRuntime from "@babel/runtime/regenerator"; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } import { baseUniDriverFactory } from '../../test/utils/unidriver'; import { testkit } from '../Input/Input.uni.driver'; import { tickerDriverFactory } from '../Input/Ticker/Ticker.uni.driver'; import { dataHooks } from './constants'; export var timeInputUniDriverFactory = function timeInputUniDriverFactory(base, body) { var amPmIndicator = function amPmIndicator() { return base.$("[data-hook=\"".concat(dataHooks.amPmIndicator, "\"]")); }; var input = testkit(base.$("[data-hook=\"".concat(dataHooks.input, "\"]")), body); var inputTicker = tickerDriverFactory(base); return _objectSpread(_objectSpread({}, baseUniDriverFactory(base)), {}, { /** * Gets TimeInput value * @returns {Promise<string>} */ getValue: function () { var _getValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: return _context.abrupt("return", input.getValue()); case 1: case "end": return _context.stop(); } } }, _callee); })); function getValue() { return _getValue.apply(this, arguments); } return getValue; }(), /** * Checks if TimeInput is disabled * @returns {Promise<boolean>} */ isDisabled: function () { var _isDisabled = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: return _context2.abrupt("return", input.isDisabled()); case 1: case "end": return _context2.stop(); } } }, _callee2); })); function isDisabled() { return _isDisabled.apply(this, arguments); } return isDisabled; }(), /** * Clicks on TimeInput up ticker * @returns {Promise<void>} */ clickTickerUp: function () { var _clickTickerUp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() { return _regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: return _context3.abrupt("return", inputTicker.clickUp()); case 1: case "end": return _context3.stop(); } } }, _callee3); })); function clickTickerUp() { return _clickTickerUp.apply(this, arguments); } return clickTickerUp; }(), /** * Clicks on TimeInput down ticker * @returns {Promise<void>} */ clickTickerDown: function () { var _clickTickerDown = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() { return _regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: return _context4.abrupt("return", inputTicker.clickDown()); case 1: case "end": return _context4.stop(); } } }, _callee4); })); function clickTickerDown() { return _clickTickerDown.apply(this, arguments); } return clickTickerDown; }(), /** * Checks whether the AM/PM indicator/toggle exists * @returns {Promise<boolean>} */ isAmPmIndicatorExist: function () { var _isAmPmIndicatorExist = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() { return _regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: return _context5.abrupt("return", amPmIndicator().exists()); case 1: case "end": return _context5.stop(); } } }, _callee5); })); function isAmPmIndicatorExist() { return _isAmPmIndicatorExist.apply(this, arguments); } return isAmPmIndicatorExist; }(), /** * Toggles AM/PM indicator * @returns {Promise<void>} */ toggleAmPmIndicator: function () { var _toggleAmPmIndicator = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() { return _regeneratorRuntime.wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: return _context6.abrupt("return", amPmIndicator().click()); case 1: case "end": return _context6.stop(); } } }, _callee6); })); function toggleAmPmIndicator() { return _toggleAmPmIndicator.apply(this, arguments); } return toggleAmPmIndicator; }(), /** * Gets the AM/PM indicator text * @returns {Promise<string>} */ getAmPmIndicatorText: function () { var _getAmPmIndicatorText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() { return _regeneratorRuntime.wrap(function _callee7$(_context7) { while (1) { switch (_context7.prev = _context7.next) { case 0: return _context7.abrupt("return", amPmIndicator().text()); case 1: case "end": return _context7.stop(); } } }, _callee7); })); function getAmPmIndicatorText() { return _getAmPmIndicatorText.apply(this, arguments); } return getAmPmIndicatorText; }(), /** * Gets the custom suffix * @returns {Promise<string>} */ getCustomSuffix: function getCustomSuffix() { return base.$("[data-hook=\"".concat(dataHooks.customSuffix, "\"]"))._prop('innerHTML'); }, /** * Checks if TimeInput is RTL * @returns {Promise<boolean>} */ isRtl: function () { var _isRtl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() { return _regeneratorRuntime.wrap(function _callee8$(_context8) { while (1) { switch (_context8.prev = _context8.next) { case 0: return _context8.abrupt("return", input.isRTL()); case 1: case "end": return _context8.stop(); } } }, _callee8); })); function isRtl() { return _isRtl.apply(this, arguments); } return isRtl; }(), /** * Set value to display in the TimeInput * @param {string} value text value to input * @returns {Promise<void>} */ setValue: function () { var _setValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(value) { return _regeneratorRuntime.wrap(function _callee9$(_context9) { while (1) { switch (_context9.prev = _context9.next) { case 0: return _context9.abrupt("return", input.enterText(value)); case 1: case "end": return _context9.stop(); } } }, _callee9); })); function setValue(_x) { return _setValue.apply(this, arguments); } return setValue; }(), /** * Trigger blur on the TimeInput * @returns {Promise<void>} */ blur: function () { var _blur = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() { return _regeneratorRuntime.wrap(function _callee10$(_context10) { while (1) { switch (_context10.prev = _context10.next) { case 0: return _context10.abrupt("return", input.blur()); case 1: case "end": return _context10.stop(); } } }, _callee10); })); function blur() { return _blur.apply(this, arguments); } return blur; }(), /** * Checks if TimeInput displayed with seconds * @returns {Promise<boolean>} */ isShowSeconds: function () { var _isShowSeconds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() { return _regeneratorRuntime.wrap(function _callee11$(_context11) { while (1) { switch (_context11.prev = _context11.next) { case 0: return _context11.abrupt("return", input.getValue().then(function (result) { return result.length === 8; })); case 1: case "end": return _context11.stop(); } } }, _callee11); })); function isShowSeconds() { return _isShowSeconds.apply(this, arguments); } return isShowSeconds; }(), /** * Checks if TimeInput has status * @param {string} status status to check * @returns {Promise<boolean>} */ hasStatus: function hasStatus(status) { return input.hasStatus(status); }, /** * Gets TimeInput status message * @returns {Promise<string | null>} */ getStatusMessage: function getStatusMessage() { return input.getStatusMessage(); } }); };