UNPKG

wix-style-react

Version:
325 lines (275 loc) • 10.5 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; 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 _regeneratorRuntime from "@babel/runtime/regenerator"; import { baseUniDriverFactory } from '../../test/utils/unidriver'; import { DataHooks } from './constants'; export var colorPickerUniDriverFactory = function colorPickerUniDriverFactory(base) { var getConverter = function getConverter() { return base.$("[data-hook=\"".concat(DataHooks.converter, "\"]")); }; var getConverterTabs = /*#__PURE__*/function () { var _ref = _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", getConverter().$$("li")); case 1: case "end": return _context.stop(); } } }, _callee); })); return function getConverterTabs() { return _ref.apply(this, arguments); }; }(); return _objectSpread(_objectSpread({}, baseUniDriverFactory(base)), {}, { /** * Clicks the confirm button * @returns {Promise<Void>} * */ confirm: function () { var _confirm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: return _context2.abrupt("return", base.$("[data-hook=\"".concat(DataHooks.confirmButton, "\"]")).click()); case 1: case "end": return _context2.stop(); } } }, _callee2); })); function confirm() { return _confirm.apply(this, arguments); } return confirm; }(), /** * Clicks the cancel button * @returns {Promise<Void>} * */ cancel: function () { var _cancel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() { return _regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: return _context3.abrupt("return", base.$("[data-hook=\"".concat(DataHooks.cancelButton, "\"]")).click()); case 1: case "end": return _context3.stop(); } } }, _callee3); })); function cancel() { return _cancel.apply(this, arguments); } return cancel; }(), /** * Clicks the previous color selection * @returns {Promise<Void>} */ clickOnPreviousColor: function () { var _clickOnPreviousColor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() { return _regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: return _context4.abrupt("return", base.$("[data-hook=\"".concat(DataHooks.historyPrevious, "\"]")).click()); case 1: case "end": return _context4.stop(); } } }, _callee4); })); function clickOnPreviousColor() { return _clickOnPreviousColor.apply(this, arguments); } return clickOnPreviousColor; }(), /** * Checks whether the history panel exists * @returns {Promise<boolean>} */ historyPanelExists: function () { var _historyPanelExists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() { return _regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: return _context5.abrupt("return", base.$("[data-hook=\"".concat(DataHooks.history, "\"]")).exists()); case 1: case "end": return _context5.stop(); } } }, _callee5); })); function historyPanelExists() { return _historyPanelExists.apply(this, arguments); } return historyPanelExists; }(), /** * Gets the current selected color * @returns {Promise<string>} */ historyCurrentColor: function () { var _historyCurrentColor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() { return _regeneratorRuntime.wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: _context6.next = 2; return base.$("[data-hook=\"".concat(DataHooks.historyCurrent, "\"]"))._prop('style'); case 2: return _context6.abrupt("return", _context6.sent.background); case 3: case "end": return _context6.stop(); } } }, _callee6); })); function historyCurrentColor() { return _historyCurrentColor.apply(this, arguments); } return historyCurrentColor; }(), /** * Gets the previous color selected * @returns {Promise<string>} */ historyPreviousColor: function () { var _historyPreviousColor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() { return _regeneratorRuntime.wrap(function _callee7$(_context7) { while (1) { switch (_context7.prev = _context7.next) { case 0: _context7.next = 2; return base.$("[data-hook=\"".concat(DataHooks.historyPrevious, "\"]"))._prop('style'); case 2: return _context7.abrupt("return", _context7.sent.background); case 3: case "end": return _context7.stop(); } } }, _callee7); })); function historyPreviousColor() { return _historyPreviousColor.apply(this, arguments); } return historyPreviousColor; }(), /** * Clicks the add new color button * @returns {Promise<Void>} */ clickAddColor: function () { var _clickAddColor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() { return _regeneratorRuntime.wrap(function _callee8$(_context8) { while (1) { switch (_context8.prev = _context8.next) { case 0: return _context8.abrupt("return", base.$("[data-hook=".concat(DataHooks.addColor, "]")).click()); case 1: case "end": return _context8.stop(); } } }, _callee8); })); function clickAddColor() { return _clickAddColor.apply(this, arguments); } return clickAddColor; }(), /** * Gets children nodes * @returns {Promise<node>} */ getChildren: function () { var _getChildren = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() { return _regeneratorRuntime.wrap(function _callee9$(_context9) { while (1) { switch (_context9.prev = _context9.next) { case 0: return _context9.abrupt("return", base.$("[data-hook=\"".concat(DataHooks.children, "\"]"))); case 1: case "end": return _context9.stop(); } } }, _callee9); })); function getChildren() { return _getChildren.apply(this, arguments); } return getChildren; }(), /** * Clicks on RGB tab * @returns {Promise<Void>} */ selectRgbTab: function () { var _selectRgbTab = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() { return _regeneratorRuntime.wrap(function _callee10$(_context10) { while (1) { switch (_context10.prev = _context10.next) { case 0: _context10.next = 2; return getConverterTabs(); case 2: return _context10.abrupt("return", _context10.sent.get(1).click()); case 3: case "end": return _context10.stop(); } } }, _callee10); })); function selectRgbTab() { return _selectRgbTab.apply(this, arguments); } return selectRgbTab; }(), /** * Clicks on HSB tab * @returns {Promise<Void>} */ selectHsbTab: function () { var _selectHsbTab = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() { return _regeneratorRuntime.wrap(function _callee11$(_context11) { while (1) { switch (_context11.prev = _context11.next) { case 0: _context11.next = 2; return getConverterTabs(); case 2: return _context11.abrupt("return", _context11.sent.get(2).click()); case 3: case "end": return _context11.stop(); } } }, _callee11); })); function selectHsbTab() { return _selectHsbTab.apply(this, arguments); } return selectHsbTab; }() }); }; export default colorPickerUniDriverFactory;