UNPKG

wix-style-react

Version:
214 lines (180 loc) • 7.3 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 { loaderUniDriverFactory } from '../Loader/Loader.uni.driver'; import { textUniDriverFactory } from '../Text/Text.uni.driver'; import { tooltipDriverFactory } from '../Tooltip/Tooltip.uni.driver'; import { trendIndicatorDriverFactory } from '../TrendIndicator/TrendIndicator.uni.driver'; import { dataHooks } from './constants'; export var analyticsSummaryCardDriverFactory = function analyticsSummaryCardDriverFactory(base, body) { var getLoader = function getLoader() { return loaderUniDriverFactory(findByHook(base, dataHooks.analyticsSummaryCardLoader)); }; var _getValue = function getValue() { return textUniDriverFactory(findByHook(base, dataHooks.analyticsSummaryCardValue)); }; var _getTitle = function getTitle() { return textUniDriverFactory(findByHook(base, dataHooks.analyticsSummaryCardTitle)); }; var getValueTooltip = function getValueTooltip() { return tooltipDriverFactory(base.$("[data-hook=\"".concat(dataHooks.analyticsSummaryCardValueTooltip, "\"]")), body); }; var getTitleTooltip = function getTitleTooltip() { return tooltipDriverFactory(base.$("[data-hook=\"".concat(dataHooks.analyticsSummaryCardTitleTooltip, "\"]")), body); }; var getTrendIndicator = function getTrendIndicator() { return trendIndicatorDriverFactory(findByHook(base, dataHooks.analyticsSummaryCardTrend)); }; var getTooltipText = function getTooltipText(tooltip) { return tooltip.getTooltipText(); }; return _objectSpread(_objectSpread({}, baseUniDriverFactory(base, body)), {}, { /** * Click on CTA * @returns {Promise<React.MouseEventHandler<HTMLButtonElement>>} */ clickCTA: function () { var _clickCTA = _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 base.hover(); case 2: _context.next = 4; return findByHook(base, dataHooks.analyticsSummaryCardCTA).click(); case 4: case "end": return _context.stop(); } } }, _callee); })); function clickCTA() { return _clickCTA.apply(this, arguments); } return clickCTA; }(), /** * Check if CTA exists * @returns {boolean} */ CTAExists: function () { var _CTAExists = _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 base.hover(); case 2: return _context2.abrupt("return", findByHook(base, dataHooks.analyticsSummaryCardCTA).exists()); case 3: case "end": return _context2.stop(); } } }, _callee2); })); function CTAExists() { return _CTAExists.apply(this, arguments); } return CTAExists; }(), /** * Checks whether the Analytics are loading * @returns {Promise<boolean>} */ isLoading: function isLoading() { return getLoader().exists(); }, /** * returns the value text * @returns {Promise<string>} */ getValue: function getValue() { return _getValue().getText(); }, /** * returns the value tooltip text * @returns {Promise<string>} */ getValueTooltipText: function () { var _getValueTooltipText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() { return _regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.t0 = getTooltipText; _context3.next = 3; return getValueTooltip(); case 3: _context3.t1 = _context3.sent; return _context3.abrupt("return", (0, _context3.t0)(_context3.t1)); case 5: case "end": return _context3.stop(); } } }, _callee3); })); function getValueTooltipText() { return _getValueTooltipText.apply(this, arguments); } return getValueTooltipText; }(), /** * returns the title text * @returns {Promise<string>} */ getTitle: function getTitle() { return _getTitle().getText(); }, /** * returns the title tooltip text * @returns {Promise<string>} */ getTitleTooltipText: function () { var _getTitleTooltipText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() { return _regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.t0 = getTooltipText; _context4.next = 3; return getTitleTooltip(); case 3: _context4.t1 = _context4.sent; return _context4.abrupt("return", (0, _context4.t0)(_context4.t1)); case 5: case "end": return _context4.stop(); } } }, _callee4); })); function getTitleTooltipText() { return _getTitleTooltipText.apply(this, arguments); } return getTitleTooltipText; }(), /** * checks if trend exists * @returns {Promise<boolean>} */ trendExists: function trendExists() { return getTrendIndicator().exists(); }, /** * returns the trend value * @returns {Promise<number>} */ getTrendvalue: function getTrendvalue() { return getTrendIndicator().getTrendValue(); } }); };