wix-style-react
Version:
wix-style-react
41 lines (40 loc) • 2.21 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));
var _constants = require("./constants");
var notificationDriverFactory = _ref => {
var {
element
} = _ref;
var getElementByDataHook = dataHook => element.querySelector("[data-hook=\"".concat(dataHook, "\"]"));
var notificationContent = () => getElementByDataHook(_constants.dataHooks.notificationContent);
var labelText = () => getElementByDataHook(_constants.dataHooks.notificationLabel);
var actionButton = () => getElementByDataHook(_constants.dataHooks.notificationCtaButton);
var closeButton = () => getElementByDataHook(_constants.dataHooks.notificationCloseButton);
var getTheme = () => element.getAttribute('data-theme');
var getType = () => element.getAttribute('data-type');
return {
exists: () => !!element,
visible: () => !!notificationContent(),
hasTheme: () => !!getTheme(),
isStandardNotification: () => getTheme() === _constants.THEMES.standard,
isErrorNotification: () => getTheme() === _constants.THEMES.error,
isSuccessNotification: () => getTheme() === _constants.THEMES.success,
isWarningNotification: () => getTheme() === _constants.THEMES.warning,
isPremiumNotification: () => getTheme() === _constants.THEMES.premium,
getLabelText: () => labelText().textContent,
hasActionButton: () => !!actionButton(),
getActionButtonText: () => actionButton().textContent,
hasCloseButton: () => !!closeButton(),
isRelativelyPositioned: () => getType() === _constants.TYPE_POSITIONS_MAP.relative,
isFixedPositioned: () => getType() === _constants.TYPE_POSITIONS_MAP.fixed,
isAbsolutePositioned: () => getType() === _constants.TYPE_POSITIONS_MAP.absolute,
clickOnCloseButton: () => _testUtils.default.Simulate.click(closeButton()),
clickOnActionButton: () => _testUtils.default.Simulate.click(actionButton()),
getZIndex: () => Number(element.style['z-index'])
};
};
var _default = exports.default = notificationDriverFactory;
//# sourceMappingURL=Notification.driver.js.map