UNPKG

wix-style-react

Version:
70 lines (57 loc) 3.24 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 } from 'wix-ui-test-utils/base-driver'; import { dataHooks } from './constants'; export var modalPreviewLayoutDriverFactory = function modalPreviewLayoutDriverFactory(base) { var getPreviewContent = function getPreviewContent() { return base.$("[data-hook=\"".concat(dataHooks.modalPreviewContent, "\"]")); }; return _objectSpread(_objectSpread({}, baseUniDriverFactory(base)), {}, { /** Click the overlay */ clickOverlay: function clickOverlay() { return base.$("[data-hook=\"".concat(dataHooks.innerOverlay, "\"]")).click(); }, /** Get the title node */ getPreviewTitle: function getPreviewTitle() { return base.$("[data-hook=\"".concat(dataHooks.modalPreviewTitle, "\"]")); }, /** Get the actions node */ getPreviewActions: function getPreviewActions() { return base.$("[data-hook=\"".concat(dataHooks.modalPreviewActions, "\"]")); }, /** Get the content node */ getPreviewContent: getPreviewContent, /** Click the close button */ clickClose: function clickClose() { return base.$("[data-hook=\"".concat(dataHooks.modalPreviewCloseButton, "\"]")).click(); }, /** Get the index of the rendered child */ getCurrentChildIndex: function () { var _getCurrentChildIndex = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.t0 = Number; _context.next = 3; return getPreviewContent().attr('data-index'); case 3: _context.t1 = _context.sent; return _context.abrupt("return", (0, _context.t0)(_context.t1)); case 5: case "end": return _context.stop(); } } }, _callee); })); function getCurrentChildIndex() { return _getCurrentChildIndex.apply(this, arguments); } return getCurrentChildIndex; }() }); };