UNPKG

wix-style-react

Version:
133 lines (112 loc) 5.48 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 skeletonUniDriverFactory = function skeletonUniDriverFactory(base, body) { return _objectSpread(_objectSpread({}, baseUniDriverFactory(base, body)), {}, { /** return number of lines rendered */ getNumLines: function getNumLines() { return base.$$("[data-hook=\"".concat(dataHooks.line, "\"]")).count(); }, /** return boolean representing whether given spacing is rendered */ hasSpacing: function () { var _hasSpacing = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(spacing) { return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return base.attr('data-spacing'); case 2: _context.t0 = _context.sent; _context.t1 = spacing; return _context.abrupt("return", _context.t0 === _context.t1); case 5: case "end": return _context.stop(); } } }, _callee); })); function hasSpacing(_x) { return _hasSpacing.apply(this, arguments); } return hasSpacing; }(), /** return boolean representing whether given list of sizes is rendered */ hasSizes: function () { var _hasSizes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(sizes) { var assertions; return _regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return base.$$("[data-hook=\"".concat(dataHooks.chunk, "\"]")).map( /*#__PURE__*/function () { var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(chunkElement, i) { return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return chunkElement.attr('data-size'); case 2: _context2.t0 = _context2.sent; _context2.t1 = sizes[i]; return _context2.abrupt("return", _context2.t0 === _context2.t1); case 5: case "end": return _context2.stop(); } } }, _callee2); })); return function (_x3, _x4) { return _ref.apply(this, arguments); }; }()); case 2: assertions = _context3.sent; return _context3.abrupt("return", assertions.every(Boolean)); case 4: case "end": return _context3.stop(); } } }, _callee3); })); function hasSizes(_x2) { return _hasSizes.apply(this, arguments); } return hasSizes; }(), /** return boolean representing whether given alignment is rendered */ hasAlignment: function () { var _hasAlignment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(alignment) { return _regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.next = 2; return base.attr('data-alignment'); case 2: _context4.t0 = _context4.sent; _context4.t1 = alignment; return _context4.abrupt("return", _context4.t0 === _context4.t1); case 5: case "end": return _context4.stop(); } } }, _callee4); })); function hasAlignment(_x5) { return _hasAlignment.apply(this, arguments); } return hasAlignment; }() }); };