wix-style-react
Version:
149 lines (120 loc) • 5.16 kB
JavaScript
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';
export var floatingHelperContentUniDriverFactory = function floatingHelperContentUniDriverFactory(base, body) {
var title = findByHook(body, dataHooks.title);
var floatingHelperBody = findByHook(body, dataHooks.body);
var image = findByHook(body, dataHooks.image);
var actionButton = findByHook(body, dataHooks.actionButton);
var footer = findByHook(body, dataHooks.footer);
return _objectSpread(_objectSpread({}, baseUniDriverFactory(base, body)), {}, {
/** checks if title exists */
hasTitle: function hasTitle() {
return title.exists();
},
/** checks if text content exists */
hasBody: function hasBody() {
return floatingHelperBody.exists();
},
/** checks if the action button exists */
hasActionButton: function hasActionButton() {
return actionButton.exists();
},
/** checks if the footer exists */
hasFooter: function hasFooter() {
return footer.exists();
},
/** checks if an image exists */
hasImage: function hasImage() {
return image.exists();
},
/** Get image HTML element*/
getImage: function () {
var _getImage = _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 image.exists();
case 2:
_context.t0 = _context.sent;
if (!_context.t0) {
_context.next = 7;
break;
}
_context.next = 6;
return image.getNative();
case 6:
_context.t0 = _context.sent.children[0];
case 7:
return _context.abrupt("return", _context.t0);
case 8:
case "end":
return _context.stop();
}
}
}, _callee);
}));
function getImage() {
return _getImage.apply(this, arguments);
}
return getImage;
}(),
// eslint-disable-line no-restricted-properties
/** Get footer HTML element*/
getFooter: function () {
var _getFooter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return footer.exists();
case 2:
_context2.t0 = _context2.sent;
if (!_context2.t0) {
_context2.next = 7;
break;
}
_context2.next = 6;
return footer.getNative();
case 6:
_context2.t0 = _context2.sent.children[0];
case 7:
return _context2.abrupt("return", _context2.t0);
case 8:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
function getFooter() {
return _getFooter.apply(this, arguments);
}
return getFooter;
}(),
// eslint-disable-line no-restricted-properties
/** Get the text content of the title */
getTitleContent: function getTitleContent() {
return title.text();
},
/** Get the text content of the helper's text */
getBodyContent: function getBodyContent() {
return floatingHelperBody.text();
},
/** Get text of action button */
getActionButtonText: function getActionButtonText() {
return actionButton.text();
},
/** click on the action button */
clickActionButton: function clickActionButton() {
return actionButton.click();
}
});
};