@wix/design-system
Version:
@wix/design-system
107 lines (106 loc) • 4.52 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.sectionHelperUniDriverFactory = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _unidriver = require("../utils/test-utils/unidriver");
var _ButtonUni = require("../Button/Button.uni.driver");
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 sectionHelperUniDriverFactory = base => {
var actionButtonDriver = () => (0, _ButtonUni.buttonDriverFactory)(base.$("[data-hook=\"".concat(_constants.dataHooks.actionButton, "\"]")));
var closeButtonDriver = () => (0, _ButtonUni.buttonDriverFactory)(base.$("[data-hook=\"".concat(_constants.dataHooks.closeButton, "\"]")));
var hasSkin = /*#__PURE__*/function () {
var _ref = (0, _asyncToGenerator2.default)(function* (skin) {
return (yield base.attr('data-skin')) === skin;
});
return function hasSkin(_x) {
return _ref.apply(this, arguments);
};
}();
var getPrefix = () => (0, _unidriver.findByHook)(base, _constants.dataHooks.prefix);
return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, {
/**
* Gets the title text
* @return {Promise<string>}
*/
titleText: () => base.$("[data-hook=\"".concat(_constants.dataHooks.title, "\"]")).text(),
/**
* Gets the action text
* @return {Promise<string>}
*/
actionText: () => actionButtonDriver().getButtonTextContent(),
/**
* Clicks the action
* @return {Promise<void>}
*/
clickAction: () => actionButtonDriver().click(),
/**
* Clicks the close button
* @return {Promise<void>}
*/
clickClose: () => closeButtonDriver().click(),
/**
* Checks whether the close button is displayed
* @return {Promise<boolean>}
*/
isCloseButtonDisplayed: () => closeButtonDriver().exists(),
/**
* Checks whether the prefix is displayed
* @return {Promise<boolean>}
*/
hasPrefix: function () {
var _hasPrefix = (0, _asyncToGenerator2.default)(function* () {
return getPrefix().exists();
});
function hasPrefix() {
return _hasPrefix.apply(this, arguments);
}
return hasPrefix;
}(),
/**
* Gets the text content
* @return {Promise<string>}
*/
textContent: () => base.text(),
/**
* Checks whether the component appears as "warning"
* @return {Promise<boolean>}
*/
isWarning: () => hasSkin(_constants.SKIN.Warning),
/**
* Checks whether the component appears as "standard"
* @return {Promise<boolean>}
*/
isStandard: () => hasSkin(_constants.SKIN.Standard),
/**
* Checks whether the component appears as "danger"
* @return {Promise<boolean>}
*/
isDanger: () => hasSkin(_constants.SKIN.Danger),
/**
* Checks whether the component appears as "experimentalDark"
* @return {Promise<boolean>}
*/
isExperimentalDark: () => hasSkin(_constants.SKIN.ExperimentalDark),
/**
* Checks whether the component appears as "success"
* @return {Promise<boolean>}
*/
isSuccess: () => hasSkin(_constants.SKIN.Success),
/**
* Checks whether the component appears as "premium"
* @return {Promise<boolean>}
*/
isPremium: () => hasSkin(_constants.SKIN.Premium),
/**
* Checks whether the component appears as "preview"
* @return {Promise<boolean>}
*/
isPreview: () => hasSkin(_constants.SKIN.Preview)
});
};
exports.sectionHelperUniDriverFactory = sectionHelperUniDriverFactory;
//# sourceMappingURL=SectionHelper.uni.driver.js.map