wix-style-react
Version:
363 lines (303 loc) • 11.5 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.timeInputUniDriverFactory = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _unidriver = require("../../test/utils/unidriver");
var _InputUni = require("../Input/Input.uni.driver");
var _TickerUni = require("../Input/Ticker/Ticker.uni.driver");
var _constants = require("./constants");
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) { (0, _defineProperty2["default"])(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; }
var timeInputUniDriverFactory = function timeInputUniDriverFactory(base, body) {
var amPmIndicator = function amPmIndicator() {
return base.$("[data-hook=\"".concat(_constants.dataHooks.amPmIndicator, "\"]"));
};
var input = (0, _InputUni.testkit)(base.$("[data-hook=\"".concat(_constants.dataHooks.input, "\"]")), body);
var inputTicker = (0, _TickerUni.tickerDriverFactory)(base);
return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, {
/**
* Gets TimeInput value
* @returns {Promise<string>}
*/
getValue: function () {
var _getValue = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
return _regenerator["default"].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 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
return _regenerator["default"].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 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
return _regenerator["default"].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 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
return _regenerator["default"].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 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
return _regenerator["default"].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 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
return _regenerator["default"].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 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
return _regenerator["default"].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(_constants.dataHooks.customSuffix, "\"]"))._prop('innerHTML');
},
/**
* Checks if TimeInput is RTL
* @returns {Promise<boolean>}
*/
isRtl: function () {
var _isRtl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
return _regenerator["default"].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 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(value) {
return _regenerator["default"].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 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
return _regenerator["default"].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 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
return _regenerator["default"].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();
}
});
};
exports.timeInputUniDriverFactory = timeInputUniDriverFactory;