wix-style-react
Version:
wix-style-react
102 lines (101 loc) • 5.15 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.featureListDriverFactory = void 0;
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _unidriver = require("../test-utils/utils/unidriver");
var _constants = require("./constants");
var _TextUni = require("../Text/Text.uni.driver");
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 featureListDriverFactory = (base, body) => {
return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base, body)), {}, {
/**
* Gets the number of the features that exist in the footer
* @returns {Promise<number>}
*/
getNumberOfFeatures: function () {
var _getNumberOfFeatures = (0, _asyncToGenerator2.default)(function* () {
return (0, _unidriver.countByHook)(base, _constants.dataHooks.feature);
});
function getNumberOfFeatures() {
return _getNumberOfFeatures.apply(this, arguments);
}
return getNumberOfFeatures;
}(),
/**
* Checks whether feature's title exist
* @param {number} featureIndex - the index of the feature in the features array (starts from 0)
* @returns {Promise<boolean>}
*/
hasFeatureTitle: function () {
var _hasFeatureTitle = (0, _asyncToGenerator2.default)(function* (featureIndex) {
return yield (0, _unidriver.findByHook)(base, "".concat(_constants.dataHooks.featureTitle).concat(featureIndex)).exists();
});
function hasFeatureTitle(_x) {
return _hasFeatureTitle.apply(this, arguments);
}
return hasFeatureTitle;
}(),
/**
* Gets the feature's title
* @param {number} featureIndex - the index of the feature in the features array (starts from 0)
* @returns {Promise<string>}
*/
getFeatureTitle: function () {
var _getFeatureTitle = (0, _asyncToGenerator2.default)(function* (featureIndex) {
return (yield (0, _TextUni.textUniDriverFactory)(yield (0, _unidriver.findByHook)(base, "".concat(_constants.dataHooks.featureTitle).concat(featureIndex)))).getText();
});
function getFeatureTitle(_x2) {
return _getFeatureTitle.apply(this, arguments);
}
return getFeatureTitle;
}(),
/**
* Checks whether feature's text exist
* @param {number} featureIndex - the index of the feature in the features array (starts from 0)
* @returns {Promise<boolean>}
*/
hasFeatureText: function () {
var _hasFeatureText = (0, _asyncToGenerator2.default)(function* (featureIndex) {
return yield (0, _unidriver.findByHook)(base, "".concat(_constants.dataHooks.featureText).concat(featureIndex)).exists();
});
function hasFeatureText(_x3) {
return _hasFeatureText.apply(this, arguments);
}
return hasFeatureText;
}(),
/**
* Gets the feature's text
* @param {number} featureIndex - the index of the feature in the features array (starts from 0)
* @returns {Promise<string>}
*/
getFeatureText: function () {
var _getFeatureText = (0, _asyncToGenerator2.default)(function* (featureIndex) {
return (yield (0, _TextUni.textUniDriverFactory)(yield (0, _unidriver.findByHook)(base, "".concat(_constants.dataHooks.featureText).concat(featureIndex)))).getText();
});
function getFeatureText(_x4) {
return _getFeatureText.apply(this, arguments);
}
return getFeatureText;
}(),
/**
* Checks whether the feature has an image node with the given predicate.
* @param {number} featureIndex - the index of the feature in the features array (starts from 0)
* @param {string} predicate - a predicate for the image node
* @returns {Promise<boolean>}
*/
hasFeatureImage: function () {
var _hasFeatureImage = (0, _asyncToGenerator2.default)(function* (featureIndex, predicate) {
return yield (0, _unidriver.findByHook)(base, "".concat(_constants.dataHooks.featureImage).concat(featureIndex)).$(predicate).exists();
});
function hasFeatureImage(_x5, _x6) {
return _hasFeatureImage.apply(this, arguments);
}
return hasFeatureImage;
}()
});
};
exports.featureListDriverFactory = featureListDriverFactory;
//# sourceMappingURL=FeatureList.uni.driver.js.map