UNPKG

wix-style-react

Version:
238 lines (208 loc) • 9.35 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 } from 'wix-ui-test-utils/base-driver'; import { getElement } from '../../../test/utils/unidriver'; import { buttonDriverFactory } from '../../Button/Button.uni.driver'; export var MessageBoxFunctionalLayoutUniDriverFactory = function MessageBoxFunctionalLayoutUniDriverFactory(base) { var confirmationButton = function confirmationButton() { return base.$('[data-hook="confirmation-button"]'); }; var cancellationButton = function cancellationButton() { return base.$('[data-hook="cancellation-button"]'); }; var headerCloseButton = function headerCloseButton() { return base.$('[data-hook="header-close-button"]'); }; var confirmButtonDriver = buttonDriverFactory(confirmationButton()); var cancelButtonDriver = buttonDriverFactory(cancellationButton()); return _objectSpread(_objectSpread({}, baseUniDriverFactory(base)), {}, { exists: function exists() { return base.exists(); }, getConfirmationButtonText: function getConfirmationButtonText() { return confirmButtonDriver.getButtonTextContent(); }, isConfirmationButtonPrefixIconExists: function () { var _isConfirmationButtonPrefixIconExists = _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 confirmationButton()._prop('innerHTML'); case 2: _context.t0 = _context.sent.indexOf('prefix'); _context.t1 = -1; return _context.abrupt("return", _context.t0 !== _context.t1); case 5: case "end": return _context.stop(); } } }, _callee); })); function isConfirmationButtonPrefixIconExists() { return _isConfirmationButtonPrefixIconExists.apply(this, arguments); } return isConfirmationButtonPrefixIconExists; }(), isConfirmationButtonSuffixIconExists: function () { var _isConfirmationButtonSuffixIconExists = _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 confirmationButton()._prop('innerHTML'); case 2: _context2.t0 = _context2.sent.indexOf('suffix'); _context2.t1 = -1; return _context2.abrupt("return", _context2.t0 !== _context2.t1); case 5: case "end": return _context2.stop(); } } }, _callee2); })); function isConfirmationButtonSuffixIconExists() { return _isConfirmationButtonSuffixIconExists.apply(this, arguments); } return isConfirmationButtonSuffixIconExists; }(), clickOnConfirmationButton: function clickOnConfirmationButton() { return confirmButtonDriver.click(); }, getConfirmationButton: function getConfirmationButton() { return getElement(confirmationButton()); }, getCancellationButton: function getCancellationButton() { return getElement(cancellationButton()); }, getHeaderCloseButton: function getHeaderCloseButton() { return getElement(headerCloseButton()); }, getCancellationButtonText: function getCancellationButtonText() { return cancelButtonDriver.getButtonTextContent(); }, isCancellationButtonPrefixIconExists: function () { var _isCancellationButtonPrefixIconExists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() { return _regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return cancellationButton()._prop('innerHTML'); case 2: _context3.t0 = _context3.sent.indexOf('prefix'); _context3.t1 = -1; return _context3.abrupt("return", _context3.t0 !== _context3.t1); case 5: case "end": return _context3.stop(); } } }, _callee3); })); function isCancellationButtonPrefixIconExists() { return _isCancellationButtonPrefixIconExists.apply(this, arguments); } return isCancellationButtonPrefixIconExists; }(), isCancellationButtonSuffixIconExists: function () { var _isCancellationButtonSuffixIconExists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() { return _regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.next = 2; return cancellationButton()._prop('innerHTML'); case 2: _context4.t0 = _context4.sent.indexOf('suffix'); _context4.t1 = -1; return _context4.abrupt("return", _context4.t0 !== _context4.t1); case 5: case "end": return _context4.stop(); } } }, _callee4); })); function isCancellationButtonSuffixIconExists() { return _isCancellationButtonSuffixIconExists.apply(this, arguments); } return isCancellationButtonSuffixIconExists; }(), clickOnCancellationButton: function clickOnCancellationButton() { return cancelButtonDriver.click(); }, clickOnHeaderCloseButton: function clickOnHeaderCloseButton() { return headerCloseButton().click(); }, isThemeExist: function () { var _isThemeExist = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(theme) { return _regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return base.attr('data-theme'); case 2: _context5.t0 = _context5.sent; _context5.t1 = theme; return _context5.abrupt("return", _context5.t0 === _context5.t1); case 5: case "end": return _context5.stop(); } } }, _callee5); })); function isThemeExist(_x) { return _isThemeExist.apply(this, arguments); } return isThemeExist; }(), getFooter: function getFooter() { return getElement(base.$('[data-hook="message-box-footer"]')); }, getTitle: function getTitle() { return base.$('[data-hook="header-layout-title"]').text(); }, getChildBySelector: function getChildBySelector(selector) { return getElement(base.$(selector)); }, isCancelEnable: function isCancelEnable() { return !cancelButtonDriver.isButtonDisabled(); }, isConfirmationEnable: function isConfirmationEnable() { return !confirmButtonDriver.isButtonDisabled(); }, toHaveBodyPadding: function () { var _toHaveBodyPadding = _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.attr('data-nobodypadding'); case 2: _context6.t0 = _context6.sent; return _context6.abrupt("return", _context6.t0 !== 'true'); case 4: case "end": return _context6.stop(); } } }, _callee6); })); function toHaveBodyPadding() { return _toHaveBodyPadding.apply(this, arguments); } return toHaveBodyPadding; }() }); };