wix-style-react
Version:
wix-style-react
147 lines (146 loc) • 6.11 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.addressInputDriverFactory = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _unidriver = require("../test-utils/utils/unidriver");
var _InputWithOptionsUni = require("../InputWithOptions/InputWithOptions.uni.driver");
var _LoaderUni = require("../Loader/Loader.uni.driver");
var _StatusIndicatorUni = require("../StatusIndicator/StatusIndicator.uni.driver");
var _AddressInputItemUni = require("../AddressInputItem/AddressInputItem.uni.driver");
var _constants = require("./constants");
var _constants2 = require("../Input/constants");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var addressInputDriverFactory = (base, body) => {
var {
driver,
inputDriver,
dropdownLayoutDriver
} = (0, _InputWithOptionsUni.inputWithOptionsUniDriverFactory)(base, body);
var getItemDriverAt = /*#__PURE__*/function () {
var _ref = (0, _asyncToGenerator2.default)(function* (index) {
var optionDrivers = yield dropdownLayoutDriver.options();
var item = yield optionDrivers[index].element();
return (0, _AddressInputItemUni.addressInputItemDriverFactory)(item);
});
return function getItemDriverAt(_x) {
return _ref.apply(this, arguments);
};
}();
var loaderTestkit = () => (0, _LoaderUni.loaderUniDriverFactory)((0, _unidriver.findByHook)(base, _constants.dataHooks.loader));
var statusIndicatorTestkit = () => (0, _StatusIndicatorUni.statusIndicatorDriverFactory)((0, _unidriver.findByHook)(base, _constants2.dataHooks.status));
var isDropdownLoaderShown = () => loaderTestkit().exists();
var isLoadingIndicatorShown = /*#__PURE__*/function () {
var _ref2 = (0, _asyncToGenerator2.default)(function* () {
try {
var status = yield statusIndicatorTestkit().getStatus();
return status === 'loading';
} catch (_unused) {
// Couldn't find StatusIndicator
return false;
}
});
return function isLoadingIndicatorShown() {
return _ref2.apply(this, arguments);
};
}();
return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base, body)), {}, {
/**
* Returns value of the input
* @returns {Promise<string>}
*/
getInputValue: () => inputDriver.getValue(),
/**
* Enters given text to input
* @param {string} text Text to input
* @returns {Promise<void>}
*/
enterText: text => inputDriver.enterText(text),
/**
* Clicks on the clear button to clear input text
* @returns {Promise<void>}
*/
clickClear: () => inputDriver.clickClear(),
/**
* Checks if input is disabled
* @returns {Promise<boolean>}
*/
isDisabled: () => driver.isDisabled(),
/**
* Clicks an option at given index
* @param {number} index Position of the option
* @returns {Promise<void>}
*/
clickAtOption: index => dropdownLayoutDriver.clickAtOption(index),
/**
* Clicks an option with a given value
* @param {string} value The option value
* @returns {Promise<void>}
*/
clickAtOptionWithValue: value => dropdownLayoutDriver.clickAtOptionWithValue(value),
/** Whether loader is shown
* @returns {Promise<boolean>}
*/
isLoading: function () {
var _isLoading = (0, _asyncToGenerator2.default)(function* () {
return (yield isLoadingIndicatorShown()) || (yield isDropdownLoaderShown());
});
function isLoading() {
return _isLoading.apply(this, arguments);
}
return isLoading;
}(),
/**
* Clicks on input
* @returns {Promise<void>}
*/
clickInput: () => inputDriver.click(),
/**
* Gets amount of dropdown items
* @returns {Promise<number>}
*/
getAmountOfItems: () => dropdownLayoutDriver.optionsLength(),
/**
* Gets item main label text at given index
* @param {number} index
* @returns {Promise<string>}
*/
getItemMainLabelAt: function () {
var _getItemMainLabelAt = (0, _asyncToGenerator2.default)(function* (index) {
return (yield getItemDriverAt(index)).getMainLabelText();
});
function getItemMainLabelAt(_x2) {
return _getItemMainLabelAt.apply(this, arguments);
}
return getItemMainLabelAt;
}(),
/**
* Gets item secondary label text at given index
* @param {number} index
* @returns {Promise<string>}
*/
getItemSecondaryLabelAt: function () {
var _getItemSecondaryLabelAt = (0, _asyncToGenerator2.default)(function* (index) {
return (yield getItemDriverAt(index)).getSecondaryLabelText();
});
function getItemSecondaryLabelAt(_x3) {
return _getItemSecondaryLabelAt.apply(this, arguments);
}
return getItemSecondaryLabelAt;
}(),
/**
* Press enter on address input
* @returns {Promise<void>}
*/
pressEnter: () => driver.pressKey('Enter'),
/**
* Checks whether the address input is focused
* @returns {Promise<boolean>}
*/
isFocused: () => inputDriver.isFocus()
});
};
exports.addressInputDriverFactory = addressInputDriverFactory;
//# sourceMappingURL=AddressInput.uni.driver.js.map