UNPKG

wix-style-react

Version:
80 lines (68 loc) 3.49 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, findByHookAtIndex } from '../../test/utils/unidriver'; import { tooltipDriverFactory } from '../Tooltip/Tooltip.uni.driver'; import { dataHooks } from './constants'; export var stackedBarChartDriverFactory = function stackedBarChartDriverFactory(base, body) { return _objectSpread(_objectSpread({}, baseUniDriverFactory(base, body)), {}, { /** * Gets number of tooltips * @return {Promise<number>} */ getDataLength: function () { var _getDataLength = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: return _context.abrupt("return", base.$$(["[data-hook=\"".concat(dataHooks.tooltip, "\"]")]).count()); case 1: case "end": return _context.stop(); } } }, _callee); })); function getDataLength() { return _getDataLength.apply(this, arguments); } return getDataLength; }(), /** * Gets tooltip value at index * @param {number} index Item index * @return {Promise<any>} */ getTooltipContentAt: function () { var _getTooltipContentAt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(index) { var tooltipElement, tooltipTestkit; return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return findByHookAtIndex(base, dataHooks.tooltip, index); case 2: tooltipElement = _context2.sent; tooltipTestkit = tooltipDriverFactory(tooltipElement, body); _context2.next = 6; return tooltipTestkit.getTooltipText(); case 6: return _context2.abrupt("return", _context2.sent); case 7: case "end": return _context2.stop(); } } }, _callee2); })); function getTooltipContentAt(_x) { return _getTooltipContentAt.apply(this, arguments); } return getTooltipContentAt; }() }); };