UNPKG

wix-style-react

Version:
346 lines (291 loc) • 11.1 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 } from '../../test/utils/unidriver'; import { dataHooks } from './constants'; import { textUniDriverFactory } from '../Text/Text.uni.driver'; import { headingUniDriverFactory } from '../Heading/Heading.uni.driver'; export var marketingPageLayoutContentDriverFactory = function marketingPageLayoutContentDriverFactory(base, body) { return _objectSpread(_objectSpread({}, baseUniDriverFactory(base, body)), {}, { /** * Checks whether outline exist * @returns {Promise<boolean>} */ hasOverline: function () { var _hasOverline = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return findByHook(base, dataHooks.overlineContainer).exists(); case 2: return _context.abrupt("return", _context.sent); case 3: case "end": return _context.stop(); } } }, _callee); })); function hasOverline() { return _hasOverline.apply(this, arguments); } return hasOverline; }(), /** * Gets the overline text * @returns {Promise<string>} */ getOverlineText: function () { var _getOverlineText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.t0 = textUniDriverFactory; _context2.next = 3; return findByHook(base, dataHooks.overline); case 3: _context2.t1 = _context2.sent; _context2.next = 6; return (0, _context2.t0)(_context2.t1); case 6: return _context2.abrupt("return", _context2.sent.getText()); case 7: case "end": return _context2.stop(); } } }, _callee2); })); function getOverlineText() { return _getOverlineText.apply(this, arguments); } return getOverlineText; }(), /** * Checks whether title exist * @returns {Promise<boolean>} */ hasTitle: function () { var _hasTitle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() { return _regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return findByHook(base, dataHooks.titleContainer).exists(); case 2: return _context3.abrupt("return", _context3.sent); case 3: case "end": return _context3.stop(); } } }, _callee3); })); function hasTitle() { return _hasTitle.apply(this, arguments); } return hasTitle; }(), /** * Gets the title text * @returns {Promise<string>} */ getTitleText: function () { var _getTitleText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() { return _regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.t0 = headingUniDriverFactory; _context4.next = 3; return findByHook(base, dataHooks.title); 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 getTitleText() { return _getTitleText.apply(this, arguments); } return getTitleText; }(), /** * Checks whether subtitle exist * @returns {Promise<boolean>} */ hasSubtitle: function () { var _hasSubtitle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() { return _regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return findByHook(base, dataHooks.subtitleContainer).exists(); case 2: return _context5.abrupt("return", _context5.sent); case 3: case "end": return _context5.stop(); } } }, _callee5); })); function hasSubtitle() { return _hasSubtitle.apply(this, arguments); } return hasSubtitle; }(), /** * Gets the subtitle text * @returns {Promise<string} */ getSubtitleText: function () { var _getSubtitleText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() { return _regeneratorRuntime.wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: _context6.t0 = headingUniDriverFactory; _context6.next = 3; return findByHook(base, dataHooks.subtitle); 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 getSubtitleText() { return _getSubtitleText.apply(this, arguments); } return getSubtitleText; }(), /** * Checks whether content exist * @returns {Promise<boolean>} */ hasContent: function () { var _hasContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() { return _regeneratorRuntime.wrap(function _callee7$(_context7) { while (1) { switch (_context7.prev = _context7.next) { case 0: _context7.next = 2; return findByHook(base, dataHooks.contentContainer).exists(); case 2: return _context7.abrupt("return", _context7.sent); case 3: case "end": return _context7.stop(); } } }, _callee7); })); function hasContent() { return _hasContent.apply(this, arguments); } return hasContent; }(), /** * Gets the content text * @returns {Promise<string>} */ getContentText: function () { var _getContentText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() { return _regeneratorRuntime.wrap(function _callee8$(_context8) { while (1) { switch (_context8.prev = _context8.next) { case 0: _context8.t0 = textUniDriverFactory; _context8.next = 3; return findByHook(base, dataHooks.content); case 3: _context8.t1 = _context8.sent; _context8.next = 6; return (0, _context8.t0)(_context8.t1); case 6: return _context8.abrupt("return", _context8.sent.getText()); case 7: case "end": return _context8.stop(); } } }, _callee8); })); function getContentText() { return _getContentText.apply(this, arguments); } return getContentText; }(), /** * Checks whether actions exist * @returns {Promise<boolean>} */ hasActions: function () { var _hasActions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() { return _regeneratorRuntime.wrap(function _callee9$(_context9) { while (1) { switch (_context9.prev = _context9.next) { case 0: _context9.next = 2; return findByHook(base, dataHooks.actions).exists(); case 2: return _context9.abrupt("return", _context9.sent); case 3: case "end": return _context9.stop(); } } }, _callee9); })); function hasActions() { return _hasActions.apply(this, arguments); } return hasActions; }(), /** * Checks whether a node with the provided predicate exist * @param {string} predicate - a predicate for the child node * @returns {Promise<boolean>} */ childExists: function () { var _childExists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(predicate) { return _regeneratorRuntime.wrap(function _callee10$(_context10) { while (1) { switch (_context10.prev = _context10.next) { case 0: return _context10.abrupt("return", base.$(predicate).exists()); case 1: case "end": return _context10.stop(); } } }, _callee10); })); function childExists(_x) { return _childExists.apply(this, arguments); } return childExists; }() }); };