UNPKG

wix-style-react

Version:
214 lines (181 loc) • 8.03 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, countByHook } from '../../test/utils/unidriver'; import { dataHooks } from './constants'; import { textUniDriverFactory } from '../Text/Text.uni.driver'; export var featureListDriverFactory = function featureListDriverFactory(base, body) { return _objectSpread(_objectSpread({}, baseUniDriverFactory(base, body)), {}, { /** * Gets the number of the features that exist in the footer * @returns {Promise<number>} */ getNumberOfFeatures: function () { var _getNumberOfFeatures = _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", countByHook(base, dataHooks.feature)); case 1: case "end": return _context.stop(); } } }, _callee); })); 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 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(featureIndex) { return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return findByHook(base, "".concat(dataHooks.featureTitle).concat(featureIndex)).exists(); case 2: return _context2.abrupt("return", _context2.sent); case 3: case "end": return _context2.stop(); } } }, _callee2); })); 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 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(featureIndex) { return _regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.t0 = textUniDriverFactory; _context3.next = 3; return findByHook(base, "".concat(dataHooks.featureTitle).concat(featureIndex)); case 3: _context3.t1 = _context3.sent; _context3.next = 6; return (0, _context3.t0)(_context3.t1); case 6: return _context3.abrupt("return", _context3.sent.getText()); case 7: case "end": return _context3.stop(); } } }, _callee3); })); 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 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(featureIndex) { return _regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.next = 2; return findByHook(base, "".concat(dataHooks.featureText).concat(featureIndex)).exists(); case 2: return _context4.abrupt("return", _context4.sent); case 3: case "end": return _context4.stop(); } } }, _callee4); })); 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 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(featureIndex) { return _regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: _context5.t0 = textUniDriverFactory; _context5.next = 3; return findByHook(base, "".concat(dataHooks.featureText).concat(featureIndex)); case 3: _context5.t1 = _context5.sent; _context5.next = 6; return (0, _context5.t0)(_context5.t1); case 6: return _context5.abrupt("return", _context5.sent.getText()); case 7: case "end": return _context5.stop(); } } }, _callee5); })); 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 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(featureIndex, predicate) { return _regeneratorRuntime.wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: _context6.next = 2; return findByHook(base, "".concat(dataHooks.featureImage).concat(featureIndex)).$(predicate).exists(); case 2: return _context6.abrupt("return", _context6.sent); case 3: case "end": return _context6.stop(); } } }, _callee6); })); function hasFeatureImage(_x5, _x6) { return _hasFeatureImage.apply(this, arguments); } return hasFeatureImage; }() }); };