UNPKG

wix-style-react

Version:
194 lines (171 loc) • 6.44 kB
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; import _regeneratorRuntime from "@babel/runtime/regenerator"; import { protractorUniTestkitFactoryCreator } from 'wix-ui-test-utils/protractor'; import { popoverDriverFactory } from '../Popover/Popover.uni.driver'; import { dataHooks } from './constants'; export default (function (component, _body, _ref) { var dataHook = _ref.dataHook; var getSliderTooltipDataHook = function getSliderTooltipDataHook(index) { return dataHook ? "".concat(dataHook, "-").concat(dataHooks.sliderTooltip, "-").concat(index) : "".concat(dataHooks.sliderTooltip, "-").concat(index); }; var sliderHandle = function sliderHandle(index) { return component.$("[data-hook=\"".concat(getSliderTooltipDataHook(index), "\"]")); }; var currentHandleIndex = 0; var actions = { element: function element() { return component; }, exists: function exists() { return !!component; }, handleTooltipValue: function () { var _handleTooltipValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) { var index, popoverTestkit, text; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: index = _ref2.index; popoverTestkit = protractorUniTestkitFactoryCreator(popoverDriverFactory)({ dataHook: getSliderTooltipDataHook(index) }); _context.next = 4; return popoverTestkit.mouseEnter(); case 4: _context.t0 = parseInt; _context.next = 7; return popoverTestkit.getContentElement(); case 7: _context.next = 9; return _context.sent.getText(); case 9: _context.t1 = _context.sent; text = (0, _context.t0)(_context.t1); _context.next = 13; return actions.unHoverHandle({ index: index }); case 13: return _context.abrupt("return", text); case 14: case "end": return _context.stop(); } } }, _callee); })); function handleTooltipValue(_x) { return _handleTooltipValue.apply(this, arguments); } return handleTooltipValue; }(), isHandleTooltipDisplayed: function () { var _isHandleTooltipDisplayed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { var popoverTestkit; return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: popoverTestkit = protractorUniTestkitFactoryCreator(popoverDriverFactory)({ dataHook: getSliderTooltipDataHook(currentHandleIndex) }); return _context2.abrupt("return", popoverTestkit.isContentElementExists()); case 2: case "end": return _context2.stop(); } } }, _callee2); })); function isHandleTooltipDisplayed() { return _isHandleTooltipDisplayed.apply(this, arguments); } return isHandleTooltipDisplayed; }(), hoverHandle: function () { var _hoverHandle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref3) { var index, handle; return _regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: index = _ref3.index; currentHandleIndex = index; _context3.next = 4; return actions.unHoverHandle({ index: index }); case 4: handle = sliderHandle(index); _context3.next = 7; return browser.actions().mouseMove(handle).perform(); case 7: case "end": return _context3.stop(); } } }, _callee3); })); function hoverHandle(_x2) { return _hoverHandle.apply(this, arguments); } return hoverHandle; }(), dragHandle: function () { var _dragHandle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref4) { var index, offset, ONE_DOT_MOVEMENT, handle; return _regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: index = _ref4.index, offset = _ref4.offset; ONE_DOT_MOVEMENT = 64; handle = sliderHandle(index); _context4.next = 5; return browser.actions().dragAndDrop(handle, { x: offset * ONE_DOT_MOVEMENT, y: 0 }).perform(); case 5: case "end": return _context4.stop(); } } }, _callee4); })); function dragHandle(_x3) { return _dragHandle.apply(this, arguments); } return dragHandle; }(), unHoverHandle: function () { var _unHoverHandle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref5) { var index, handle; return _regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: index = _ref5.index; currentHandleIndex = 0; handle = sliderHandle(index); _context5.next = 5; return browser.actions().mouseMove(handle).mouseMove({ x: -100, y: -100 }).perform(); case 5: case "end": return _context5.stop(); } } }, _callee5); })); function unHoverHandle(_x4) { return _unHoverHandle.apply(this, arguments); } return unHoverHandle; }() }; return actions; });