UNPKG

wix-style-react

Version:
136 lines (135 loc) • 6.14 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports.notificationUniDriverFactory = void 0; var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); var _unidriver = require("../test-utils/utils/unidriver"); var _constants = require("./constants"); function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var notificationUniDriverFactory = base => { var getElementByDataHook = dataHook => base.$("[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 = /*#__PURE__*/function () { var _ref = (0, _asyncToGenerator2.default)(function* () { return yield base.attr('data-theme'); }); return function getTheme() { return _ref.apply(this, arguments); }; }(); var getType = /*#__PURE__*/function () { var _ref2 = (0, _asyncToGenerator2.default)(function* () { return yield base.attr('data-type'); }); return function getType() { return _ref2.apply(this, arguments); }; }(); return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, { visible: () => notificationContent.exists(), hasTheme: function () { var _hasTheme = (0, _asyncToGenerator2.default)(function* () { return !!(yield getTheme()); }); function hasTheme() { return _hasTheme.apply(this, arguments); } return hasTheme; }(), isStandardNotification: function () { var _isStandardNotification = (0, _asyncToGenerator2.default)(function* () { return (yield getTheme()) === _constants.THEMES.standard; }); function isStandardNotification() { return _isStandardNotification.apply(this, arguments); } return isStandardNotification; }(), isErrorNotification: function () { var _isErrorNotification = (0, _asyncToGenerator2.default)(function* () { return (yield getTheme()) === _constants.THEMES.error; }); function isErrorNotification() { return _isErrorNotification.apply(this, arguments); } return isErrorNotification; }(), isSuccessNotification: function () { var _isSuccessNotification = (0, _asyncToGenerator2.default)(function* () { return (yield getTheme()) === _constants.THEMES.success; }); function isSuccessNotification() { return _isSuccessNotification.apply(this, arguments); } return isSuccessNotification; }(), isWarningNotification: function () { var _isWarningNotification = (0, _asyncToGenerator2.default)(function* () { return (yield getTheme()) === _constants.THEMES.warning; }); function isWarningNotification() { return _isWarningNotification.apply(this, arguments); } return isWarningNotification; }(), isPremiumNotification: function () { var _isPremiumNotification = (0, _asyncToGenerator2.default)(function* () { return (yield getTheme()) === _constants.THEMES.premium; }); function isPremiumNotification() { return _isPremiumNotification.apply(this, arguments); } return isPremiumNotification; }(), getLabelText: () => labelText.text(), hasActionButton: () => actionButton.exists(), getActionButtonText: () => actionButton.text(), hasCloseButton: () => closeButton.exists(), isRelativelyPositioned: function () { var _isRelativelyPositioned = (0, _asyncToGenerator2.default)(function* () { return (yield getType()) === _constants.TYPE_POSITIONS_MAP.relative; }); function isRelativelyPositioned() { return _isRelativelyPositioned.apply(this, arguments); } return isRelativelyPositioned; }(), isFixedPositioned: function () { var _isFixedPositioned = (0, _asyncToGenerator2.default)(function* () { return (yield getType()) === _constants.TYPE_POSITIONS_MAP.fixed; }); function isFixedPositioned() { return _isFixedPositioned.apply(this, arguments); } return isFixedPositioned; }(), isAbsolutePositioned: function () { var _isAbsolutePositioned = (0, _asyncToGenerator2.default)(function* () { return (yield getType()) === _constants.TYPE_POSITIONS_MAP.absolute; }); function isAbsolutePositioned() { return _isAbsolutePositioned.apply(this, arguments); } return isAbsolutePositioned; }(), clickOnCloseButton: () => closeButton.click(), clickOnActionButton: () => actionButton.click(), getZIndex: function () { var _getZIndex = (0, _asyncToGenerator2.default)(function* () { var style = yield base._prop('style'); return Number(style['z-index']); }); function getZIndex() { return _getZIndex.apply(this, arguments); } return getZIndex; }() }); }; exports.notificationUniDriverFactory = notificationUniDriverFactory; //# sourceMappingURL=Notification.uni.driver.js.map