wix-style-react
Version:
372 lines (319 loc) • 12.7 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
import _regeneratorRuntime from "@babel/runtime/regenerator";
import { baseUniDriverFactory } from 'wix-ui-test-utils/base-driver';
import { dataHooks, THEMES, TYPE_POSITIONS_MAP } from './constants';
export var notificationUniDriverFactory = function notificationUniDriverFactory(base) {
var getElementByDataHook = function getElementByDataHook(dataHook) {
return base.$("[data-hook=\"".concat(dataHook, "\"]"));
};
var notificationContent = getElementByDataHook(dataHooks.notificationContent);
var labelText = getElementByDataHook(dataHooks.notificationLabel);
var actionButton = getElementByDataHook(dataHooks.notificationCtaButton);
var closeButton = getElementByDataHook(dataHooks.notificationCloseButton);
var getTheme = /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return base.attr('data-theme');
case 2:
return _context.abrupt("return", _context.sent);
case 3:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return function getTheme() {
return _ref.apply(this, arguments);
};
}();
var getType = /*#__PURE__*/function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return base.attr('data-type');
case 2:
return _context2.abrupt("return", _context2.sent);
case 3:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
return function getType() {
return _ref2.apply(this, arguments);
};
}();
return _objectSpread(_objectSpread({}, baseUniDriverFactory(base)), {}, {
visible: function visible() {
return notificationContent.exists();
},
hasTheme: function () {
var _hasTheme = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return getTheme();
case 2:
return _context3.abrupt("return", !!_context3.sent);
case 3:
case "end":
return _context3.stop();
}
}
}, _callee3);
}));
function hasTheme() {
return _hasTheme.apply(this, arguments);
}
return hasTheme;
}(),
isStandardNotification: function () {
var _isStandardNotification = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.next = 2;
return getTheme();
case 2:
_context4.t0 = _context4.sent;
_context4.t1 = THEMES.standard;
return _context4.abrupt("return", _context4.t0 === _context4.t1);
case 5:
case "end":
return _context4.stop();
}
}
}, _callee4);
}));
function isStandardNotification() {
return _isStandardNotification.apply(this, arguments);
}
return isStandardNotification;
}(),
isErrorNotification: function () {
var _isErrorNotification = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_context5.next = 2;
return getTheme();
case 2:
_context5.t0 = _context5.sent;
_context5.t1 = THEMES.error;
return _context5.abrupt("return", _context5.t0 === _context5.t1);
case 5:
case "end":
return _context5.stop();
}
}
}, _callee5);
}));
function isErrorNotification() {
return _isErrorNotification.apply(this, arguments);
}
return isErrorNotification;
}(),
isSuccessNotification: function () {
var _isSuccessNotification = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
_context6.next = 2;
return getTheme();
case 2:
_context6.t0 = _context6.sent;
_context6.t1 = THEMES.success;
return _context6.abrupt("return", _context6.t0 === _context6.t1);
case 5:
case "end":
return _context6.stop();
}
}
}, _callee6);
}));
function isSuccessNotification() {
return _isSuccessNotification.apply(this, arguments);
}
return isSuccessNotification;
}(),
isWarningNotification: function () {
var _isWarningNotification = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
_context7.next = 2;
return getTheme();
case 2:
_context7.t0 = _context7.sent;
_context7.t1 = THEMES.warning;
return _context7.abrupt("return", _context7.t0 === _context7.t1);
case 5:
case "end":
return _context7.stop();
}
}
}, _callee7);
}));
function isWarningNotification() {
return _isWarningNotification.apply(this, arguments);
}
return isWarningNotification;
}(),
isPremiumNotification: function () {
var _isPremiumNotification = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
_context8.next = 2;
return getTheme();
case 2:
_context8.t0 = _context8.sent;
_context8.t1 = THEMES.premium;
return _context8.abrupt("return", _context8.t0 === _context8.t1);
case 5:
case "end":
return _context8.stop();
}
}
}, _callee8);
}));
function isPremiumNotification() {
return _isPremiumNotification.apply(this, arguments);
}
return isPremiumNotification;
}(),
getLabelText: function getLabelText() {
return labelText.text();
},
hasActionButton: function hasActionButton() {
return actionButton.exists();
},
getActionButtonText: function getActionButtonText() {
return actionButton.text();
},
hasCloseButton: function hasCloseButton() {
return closeButton.exists();
},
isRelativelyPositioned: function () {
var _isRelativelyPositioned = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
_context9.next = 2;
return getType();
case 2:
_context9.t0 = _context9.sent;
_context9.t1 = TYPE_POSITIONS_MAP.relative;
return _context9.abrupt("return", _context9.t0 === _context9.t1);
case 5:
case "end":
return _context9.stop();
}
}
}, _callee9);
}));
function isRelativelyPositioned() {
return _isRelativelyPositioned.apply(this, arguments);
}
return isRelativelyPositioned;
}(),
isFixedPositioned: function () {
var _isFixedPositioned = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
case 0:
_context10.next = 2;
return getType();
case 2:
_context10.t0 = _context10.sent;
_context10.t1 = TYPE_POSITIONS_MAP.fixed;
return _context10.abrupt("return", _context10.t0 === _context10.t1);
case 5:
case "end":
return _context10.stop();
}
}
}, _callee10);
}));
function isFixedPositioned() {
return _isFixedPositioned.apply(this, arguments);
}
return isFixedPositioned;
}(),
isAbsolutePositioned: function () {
var _isAbsolutePositioned = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
while (1) {
switch (_context11.prev = _context11.next) {
case 0:
_context11.next = 2;
return getType();
case 2:
_context11.t0 = _context11.sent;
_context11.t1 = TYPE_POSITIONS_MAP.absolute;
return _context11.abrupt("return", _context11.t0 === _context11.t1);
case 5:
case "end":
return _context11.stop();
}
}
}, _callee11);
}));
function isAbsolutePositioned() {
return _isAbsolutePositioned.apply(this, arguments);
}
return isAbsolutePositioned;
}(),
clickOnCloseButton: function clickOnCloseButton() {
return closeButton.click();
},
clickOnActionButton: function clickOnActionButton() {
return actionButton.click();
},
getZIndex: function () {
var _getZIndex = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
var style;
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
while (1) {
switch (_context12.prev = _context12.next) {
case 0:
_context12.next = 2;
return base._prop('style');
case 2:
style = _context12.sent;
return _context12.abrupt("return", Number(style['z-index']));
case 4:
case "end":
return _context12.stop();
}
}
}, _callee12);
}));
function getZIndex() {
return _getZIndex.apply(this, arguments);
}
return getZIndex;
}()
});
};