UNPKG

wix-style-react

Version:
171 lines (147 loc) • 5.6 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } exports.default = function (component) { var sliderHandles = function sliderHandles() { return component.$$('.slider-handle'); }; var sliderHandle = function sliderHandle(index) { return sliderHandles().get(index); }; var actions = { element: function element() { return component; }, exists: function exists() { return !!component; }, handleTooltipValue: function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref2) { var index = _ref2.index; var tooltip, tooltipText; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return actions.hoverHandle({ index: index }); case 2: tooltip = component.$('.slider-tooltip'); _context.next = 5; return tooltip.getText(); case 5: tooltipText = _context.sent; _context.next = 8; return actions.unHoverHandle({ index: index }); case 8: return _context.abrupt('return', Number(tooltipText)); case 9: case 'end': return _context.stop(); } } }, _callee, undefined); })); return function handleTooltipValue(_x) { return _ref.apply(this, arguments); }; }(), isHandleTooltipDisplayed: function () { var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { var toolTipDisplayWrap; return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return component.$$('.slider-tooltip').isDisplayed(); case 2: toolTipDisplayWrap = _context2.sent; return _context2.abrupt('return', Boolean(toolTipDisplayWrap[0])); case 4: case 'end': return _context2.stop(); } } }, _callee2, undefined); })); return function isHandleTooltipDisplayed() { return _ref3.apply(this, arguments); }; }(), hoverHandle: function () { var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref5) { var index = _ref5.index; var handle; return regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return actions.unHoverHandle({ index: index }); case 2: handle = sliderHandle(index); _context3.next = 5; return browser.actions().mouseMove(handle).perform(); case 5: case 'end': return _context3.stop(); } } }, _callee3, undefined); })); return function hoverHandle(_x2) { return _ref4.apply(this, arguments); }; }(), dragHandle: function () { var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(_ref7) { var index = _ref7.index, offset = _ref7.offset; var ONE_DOT_MOVEMENT, handle; return regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: ONE_DOT_MOVEMENT = 64; handle = sliderHandle(index); _context4.next = 4; return browser.actions().dragAndDrop(handle, { x: offset * ONE_DOT_MOVEMENT, y: 0 }).perform(); case 4: case 'end': return _context4.stop(); } } }, _callee4, undefined); })); return function dragHandle(_x3) { return _ref6.apply(this, arguments); }; }(), unHoverHandle: function () { var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(_ref9) { var index = _ref9.index; var handle; return regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: handle = sliderHandle(index); _context5.next = 3; return browser.actions().mouseMove(handle).mouseMove({ x: -100, y: -100 }).perform(); case 3: case 'end': return _context5.stop(); } } }, _callee5, undefined); })); return function unHoverHandle(_x4) { return _ref8.apply(this, arguments); }; }() }; return actions; };