UNPKG

wix-style-react

Version:
66 lines (62 loc) 2.56 kB
import ReactTestUtils from 'react-dom/test-utils'; import styles from './MessageBoxFunctionalLayout.scss'; 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 ReactTestUtils.Simulate.click(confirmationButton()); }, getConfirmationButton: confirmationButton, getCancellationButton: cancellationButton, getHeaderCloseButton: headerCloseButton, getCancellationButtonText: function getCancellationButtonText() { return cancellationButton().textContent; }, clickOnCancellationButton: function clickOnCancellationButton() { return ReactTestUtils.Simulate.click(cancellationButton()); }, clickOnHeaderCloseButton: function clickOnHeaderCloseButton() { return ReactTestUtils.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('' + styles.noPadding); } }; }; export default messageBoxFunctionalLayoutDriverFactory;