wix-style-react
Version:
229 lines (187 loc) • 8.94 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.testimonialListDriverFactory = 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 _constants = require("./constants");
var _TextUni = require("../Text/Text.uni.driver");
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 testimonialListDriverFactory = function testimonialListDriverFactory(base, body) {
return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base, body)), {}, {
/**
* Gets the number of the testimonials that exist in the footer
* @returns {Promise<number>}
*/
getNumberOfTestimonials: function () {
var _getNumberOfTestimonials = (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", (0, _unidriver.countByHook)(base, _constants.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 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(testimonialIndex) {
return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return (0, _unidriver.findByHook)(base, "".concat(_constants.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 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(testimonialIndex) {
return _regenerator["default"].wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return (0, _unidriver.findByHook)(base, "".concat(_constants.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 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(testimonialIndex) {
return _regenerator["default"].wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.t0 = _TextUni.textUniDriverFactory;
_context4.next = 3;
return (0, _unidriver.findByHook)(base, "".concat(_constants.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 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(testimonialIndex) {
return _regenerator["default"].wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_context5.next = 2;
return (0, _unidriver.findByHook)(base, "".concat(_constants.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 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(testimonialIndex) {
return _regenerator["default"].wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
_context6.t0 = _TextUni.textUniDriverFactory;
_context6.next = 3;
return (0, _unidriver.findByHook)(base, "".concat(_constants.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;
}()
});
};
exports.testimonialListDriverFactory = testimonialListDriverFactory;