UNPKG

wix-style-react

Version:
213 lines (182 loc) • 7.15 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, findByHook } from '../../test/utils/unidriver'; import { dataHooks } from './constants'; import inputUniDriverFactory from '../Input/Input.uni.driver'; export var TimeInputNextDriverFactory = function TimeInputNextDriverFactory(base, body) { var inputDriver = inputUniDriverFactory(findByHook(base, dataHooks.TimeInputNextInput), body); return _objectSpread(_objectSpread({}, baseUniDriverFactory(base, body)), {}, { /** * Gets passed date value * @returns {Promise<Date>} */ 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: _context.t0 = Date; _context.t1 = parseInt; _context.next = 4; return base.attr('data-value'); case 4: _context.t2 = _context.sent; _context.t3 = (0, _context.t1)(_context.t2); return _context.abrupt("return", new _context.t0(_context.t3)); case 7: case "end": return _context.stop(); } } }, _callee); })); function getValue() { return _getValue.apply(this, arguments); } return getValue; }(), /** * Sets given value as an input value * @param {string} value text value to input * @returns {Promise<void>} */ setValue: function () { var _setValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(value) { return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: return _context2.abrupt("return", inputDriver.enterText(value)); case 1: case "end": return _context2.stop(); } } }, _callee2); })); function setValue(_x) { return _setValue.apply(this, arguments); } return setValue; }(), /** * Gets passed locale * @returns {Promise<string>} */ getLocale: function () { var _getLocale = _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", base.attr('data-locale')); case 1: case "end": return _context3.stop(); } } }, _callee3); })); function getLocale() { return _getLocale.apply(this, arguments); } return getLocale; }(), /** * Gets passed timeStyle * @returns {Promise<string>} */ getTimeStyle: function () { var _getTimeStyle = _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", base.attr('data-time-style')); case 1: case "end": return _context4.stop(); } } }, _callee4); })); function getTimeStyle() { return _getTimeStyle.apply(this, arguments); } return getTimeStyle; }(), /** * Checks if TimeInput is disabled * @return {Promise<boolean>} */ isDisabled: function () { var _isDisabled = _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", inputDriver.isDisabled()); case 1: case "end": return _context5.stop(); } } }, _callee5); })); function isDisabled() { return _isDisabled.apply(this, arguments); } return isDisabled; }(), /** Checks if TimeInput has status * @param {string} status status to check * @returns {Promise<boolean>} */ hasStatus: function () { var _hasStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(status) { return _regeneratorRuntime.wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: return _context6.abrupt("return", inputDriver.hasStatus(status)); case 1: case "end": return _context6.stop(); } } }, _callee6); })); function hasStatus(_x2) { return _hasStatus.apply(this, arguments); } return hasStatus; }(), /** * Gets TimeInput status message * @returns {Promise<string | null>} */ getStatusMessage: function () { var _getStatusMessage = _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", inputDriver.getStatusMessage()); case 1: case "end": return _context7.stop(); } } }, _callee7); })); function getStatusMessage() { return _getStatusMessage.apply(this, arguments); } return getStatusMessage; }() }); };