UNPKG

wix-style-react

Version:
213 lines (180 loc) • 8.26 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 testimonialListDriverFactory = function testimonialListDriverFactory(base, body) { return _objectSpread(_objectSpread({}, baseUniDriverFactory(base, body)), {}, { /** * Gets the number of the testimonials that exist in the footer * @returns {Promise<number>} */ getNumberOfTestimonials: function () { var _getNumberOfTestimonials = _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.testimonial)); case 1: case "end": return _context.stop(); } } }, _callee); })); function getNumberOfTestimonials() { return _getNumberOfTestimonials.apply(this, arguments); } return getNumberOfTestimonials; }(), /** * Checks whether testimonial's avatar exist * @param {number} testimonialIndex - the index of the testimonial in the testimonials array (starts from 0). * @returns {Promise<boolean>} */ hasTestimonialAvatar: function () { var _hasTestimonialAvatar = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(testimonialIndex) { return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return findByHook(base, "".concat(dataHooks.testimonialAvatar).concat(testimonialIndex)).exists(); case 2: return _context2.abrupt("return", _context2.sent); case 3: case "end": return _context2.stop(); } } }, _callee2); })); function hasTestimonialAvatar(_x) { return _hasTestimonialAvatar.apply(this, arguments); } return hasTestimonialAvatar; }(), /** * Checks whether testimonial's text exist * @param {number} testimonialIndex - the index of the testimonial in the testimonials array (starts from 0). * @returns {Promise<boolean>} */ hasTestimonialText: function () { var _hasTestimonialText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(testimonialIndex) { return _regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return findByHook(base, "".concat(dataHooks.testimonialText).concat(testimonialIndex)).exists(); case 2: return _context3.abrupt("return", _context3.sent); case 3: case "end": return _context3.stop(); } } }, _callee3); })); function hasTestimonialText(_x2) { return _hasTestimonialText.apply(this, arguments); } return hasTestimonialText; }(), /** * Gets the testimonial's text * @param {number} testimonialIndex - the index of the testimonial in the testimonials array (starts from 0). * @returns {Promise<string>} */ getTestimonialText: function () { var _getTestimonialText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(testimonialIndex) { return _regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.t0 = textUniDriverFactory; _context4.next = 3; return findByHook(base, "".concat(dataHooks.testimonialText).concat(testimonialIndex)); case 3: _context4.t1 = _context4.sent; _context4.next = 6; return (0, _context4.t0)(_context4.t1); case 6: return _context4.abrupt("return", _context4.sent.getText()); case 7: case "end": return _context4.stop(); } } }, _callee4); })); function getTestimonialText(_x3) { return _getTestimonialText.apply(this, arguments); } return getTestimonialText; }(), /** * Checks whether testimonial's author name exist * @param {number} testimonialIndex - the index of the testimonial in the testimonials array (starts from 0). * @returns {Promise<boolean>} */ hasTestimonialAuthorName: function () { var _hasTestimonialAuthorName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(testimonialIndex) { return _regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return findByHook(base, "".concat(dataHooks.testimonialAuthorName).concat(testimonialIndex)).exists(); case 2: return _context5.abrupt("return", _context5.sent); case 3: case "end": return _context5.stop(); } } }, _callee5); })); function hasTestimonialAuthorName(_x4) { return _hasTestimonialAuthorName.apply(this, arguments); } return hasTestimonialAuthorName; }(), /** * Gets the testimonial's author name * @param {number} testimonialIndex - the index of the testimonial in the testimonials array (starts from 0). * @returns {Promise<string>} */ getTestimonialAuthorName: function () { var _getTestimonialAuthorName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(testimonialIndex) { return _regeneratorRuntime.wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: _context6.t0 = textUniDriverFactory; _context6.next = 3; return findByHook(base, "".concat(dataHooks.testimonialAuthorName).concat(testimonialIndex)); case 3: _context6.t1 = _context6.sent; _context6.next = 6; return (0, _context6.t0)(_context6.t1); case 6: return _context6.abrupt("return", _context6.sent.getText()); case 7: case "end": return _context6.stop(); } } }, _callee6); })); function getTestimonialAuthorName(_x5) { return _getTestimonialAuthorName.apply(this, arguments); } return getTestimonialAuthorName; }() }); };