UNPKG

@wix/design-system

Version:

@wix/design-system

43 lines (42 loc) 2.55 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports.default = void 0; var _testUtils = _interopRequireDefault(require("react-dom/test-utils")); var _Notification = require("./Notification.constants"); var _deprecationTestkitLog = _interopRequireDefault(require("../utils/deprecationTestkitLog")); var notificationDriverFactory = _ref => { var { element } = _ref; (0, _deprecationTestkitLog.default)('notificationTestkitFactory legacy testkit is deprecated and will be removed in next major release. Please use the NotificationTestkit unidriver testkit instead.'); var getElementByDataHook = dataHook => element.querySelector("[data-hook=\"".concat(dataHook, "\"]")); var notificationContent = () => getElementByDataHook(_Notification.dataHooks.notificationContent); var labelText = () => getElementByDataHook(_Notification.dataHooks.notificationLabel); var actionButton = () => getElementByDataHook(_Notification.dataHooks.notificationCtaButton); var closeButton = () => getElementByDataHook(_Notification.dataHooks.notificationCloseButton); var getTheme = () => element.getAttribute('data-skin'); var getType = () => element.getAttribute('data-type'); return { exists: () => !!element, visible: () => !!notificationContent(), hasTheme: () => !!getTheme(), isStandardNotification: () => getTheme() === _Notification.SKINS.standard, isErrorNotification: () => getTheme() === _Notification.SKINS.error, isSuccessNotification: () => getTheme() === _Notification.SKINS.success, isWarningNotification: () => getTheme() === _Notification.SKINS.warning, isPremiumNotification: () => getTheme() === _Notification.SKINS.premium, getLabelText: () => labelText().textContent, hasActionButton: () => !!actionButton(), getActionButtonText: () => actionButton().textContent, hasCloseButton: () => !!closeButton(), isRelativelyPositioned: () => getType() === _Notification.TYPE_POSITIONS_MAP.relative, isFixedPositioned: () => getType() === _Notification.TYPE_POSITIONS_MAP.fixed, isAbsolutePositioned: () => getType() === _Notification.TYPE_POSITIONS_MAP.absolute, clickOnCloseButton: () => _testUtils.default.Simulate.click(closeButton()), clickOnActionButton: () => _testUtils.default.Simulate.click(actionButton()), getZIndex: () => Number(element.style['zIndex']) }; }; var _default = exports.default = notificationDriverFactory; //# sourceMappingURL=Notification.driver.js.map