wix-style-react
Version:
wix-style-react
89 lines (80 loc) • 3.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _testUtils = require('react-dom/test-utils');
var _testUtils2 = _interopRequireDefault(_testUtils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var notificationDriverFactory = function notificationDriverFactory(_ref) {
var element = _ref.element;
var notificationWrapperSelector = '[data-hook="notification-wrapper"]';
var labelTextSelector = '[data-hook="notification-label"]';
var actionButtonSelector = '[data-hook="notification-cta-button"]';
var closeButtonSelector = '[data-hook="notification-close-button"]';
var classExists = function classExists(className) {
return element.querySelector(notificationWrapperSelector).classList.contains(className);
};
return {
exists: function exists() {
return !!element;
},
visible: function visible() {
return !!element.querySelector(notificationWrapperSelector);
},
hasTheme: function hasTheme(theme) {
return classExists(theme + 'Theme');
},
isStandardNotification: function isStandardNotification() {
return classExists('standardTheme');
},
isErrorNotification: function isErrorNotification() {
return classExists('errorTheme');
},
isSuccessNotification: function isSuccessNotification() {
return classExists('successTheme');
},
isWarningNotification: function isWarningNotification() {
return classExists('warningTheme');
},
isPremiumNotification: function isPremiumNotification() {
return classExists('premiumTheme');
},
isSmallSize: function isSmallSize() {
return classExists('smallSize');
},
isBigSize: function isBigSize() {
return classExists('bigSize');
},
getLabelText: function getLabelText() {
return element.querySelector(labelTextSelector).textContent;
},
hasActionButton: function hasActionButton() {
return !!element.querySelector(actionButtonSelector);
},
getActionButtonText: function getActionButtonText() {
return element.querySelector(actionButtonSelector).textContent;
},
hasCloseButton: function hasCloseButton() {
return !!element.querySelector('[data-hook="notification-close-button"]');
},
isRelativelyPositioned: function isRelativelyPositioned() {
return classExists('relativePosition');
},
isFixedPositioned: function isFixedPositioned() {
return classExists('fixedPosition');
},
isAbsolutePositioned: function isAbsolutePositioned() {
return classExists('absolutePosition');
},
clickOnCloseButton: function clickOnCloseButton() {
return _testUtils2.default.Simulate.click(element.querySelector(closeButtonSelector));
},
clickOnActionButton: function clickOnActionButton() {
return _testUtils2.default.Simulate.click(element.querySelector(actionButtonSelector));
},
getZIndex: function getZIndex() {
return Number(element.querySelector(notificationWrapperSelector).style['z-index']);
}
};
};
exports.default = notificationDriverFactory;