UNPKG

wix-style-react

Version:
79 lines (69 loc) 2.95 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _testUtils = require('react-dom/test-utils'); var _testUtils2 = _interopRequireDefault(_testUtils); var _MessageBoxFunctionalLayout = require('./MessageBoxFunctionalLayout.scss'); var _MessageBoxFunctionalLayout2 = _interopRequireDefault(_MessageBoxFunctionalLayout); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var messageBoxFunctionalLayoutDriverFactory = function messageBoxFunctionalLayoutDriverFactory(_ref) { var element = _ref.element; var confirmationButton = function confirmationButton() { return element.querySelector('[data-hook="confirmation-button"]'); }; var cancellationButton = function cancellationButton() { return element.querySelector('[data-hook="cancellation-button"]'); }; var headerCloseButton = function headerCloseButton() { return element.querySelector('[data-hook="header-close-button"]'); }; var body = function body() { return element.querySelector('[data-hook="message-box-body"]'); }; return { exists: function exists() { return !!element; }, getConfirmationButtonText: function getConfirmationButtonText() { return confirmationButton().textContent; }, clickOnConfirmationButton: function clickOnConfirmationButton() { return _testUtils2.default.Simulate.click(confirmationButton()); }, getConfirmationButton: confirmationButton, getCancellationButton: cancellationButton, getHeaderCloseButton: headerCloseButton, getCancellationButtonText: function getCancellationButtonText() { return cancellationButton().textContent; }, clickOnCancellationButton: function clickOnCancellationButton() { return _testUtils2.default.Simulate.click(cancellationButton()); }, clickOnHeaderCloseButton: function clickOnHeaderCloseButton() { return _testUtils2.default.Simulate.click(headerCloseButton()); }, isThemeExist: function isThemeExist(theme) { return !!element.querySelector('.' + theme); }, getFooter: function getFooter() { return element.querySelector('[data-hook="message-box-footer"]'); }, getTitle: function getTitle() { return element.querySelector('[data-hook="header-layout-title"]').textContent; }, getChildBySelector: function getChildBySelector(selector) { return element.querySelector(selector); }, isCancelEnable: function isCancelEnable() { return cancellationButton().className.indexOf('disabled') === -1; }, isConfirmationEnable: function isConfirmationEnable() { return confirmationButton().className.indexOf('disabled') === -1; }, toHaveBodyPadding: function toHaveBodyPadding() { return !body().classList.contains('' + _MessageBoxFunctionalLayout2.default.noPadding); } }; }; exports.default = messageBoxFunctionalLayoutDriverFactory;