UNPKG

wix-style-react

Version:
96 lines (95 loc) 4.28 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports.avatarUniDriverFactory = void 0; var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _unidriver = require("../test-utils/utils/unidriver"); var _constants = require("./constants"); var _IconButtonUni = require("../IconButton/IconButton.uni.driver"); var _LoaderUni = require("../Loader/Loader.uni.driver"); 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 avatarUniDriverFactory = base => { var getIndication = () => (0, _IconButtonUni.iconButtonDriverFactory)((0, _unidriver.findByHook)(base, _constants.dataHooks.indication)); var getLoader = () => (0, _LoaderUni.loaderUniDriverFactory)((0, _unidriver.findByHook)(base, _constants.dataHooks.loader)); var getCustomIndication = () => (0, _IconButtonUni.iconButtonDriverFactory)((0, _unidriver.findByHook)(base, _constants.dataHooks.customIndication)); return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, { /** * Clicks on the Avatar element * @return {Promise<void>} */ click: () => (0, _unidriver.findByHook)(base, _constants.dataHooks.avatarCore).click(), /** * Gets the content type * @returns {Promise<'text' | 'placeholder' | 'image'>} */ getContentType: () => base.attr('data-content-type'), /** * Gets the text content * @returns {Promise<string>} */ getTextContent: function () { var _getTextContent = (0, _asyncToGenerator2.default)(function* () { return yield (0, _unidriver.findByHook)(base, _constants.dataHooks.textContainer).text(); }); function getTextContent() { return _getTextContent.apply(this, arguments); } return getTextContent; }(), /** * Checks whether the image is loaded * @returns {Promise<boolean>} */ isImageLoaded: function () { var _isImageLoaded = (0, _asyncToGenerator2.default)(function* () { return (yield base.attr('data-img-loaded')) === 'true'; }); function isImageLoaded() { return _isImageLoaded.apply(this, arguments); } return isImageLoaded; }(), /** * Hovers the component * @returns {Promise<void>} */ hover: function () { var _hover = (0, _asyncToGenerator2.default)(function* () { return yield (0, _unidriver.findByHook)(base, _constants.dataHooks.avatarWSR).hover(); }); function hover() { return _hover.apply(this, arguments); } return hover; }(), /** * Checks whether the Avatar indication exists * @returns {Promise<boolean>} */ indicationExists: () => getIndication().exists(), /** * Clicks the Avatar indication * @returns {Promise<void>} */ clickIndication: () => getIndication().click(), /** * Checks whether the Avatar custom indication exists * @returns {Promise<boolean>} */ customIndicationExists: () => getCustomIndication().exists(), /** * Clicks the Avatar custom indication * @returns {Promise<void>} */ clickCustomIndication: () => getCustomIndication().click(), /** * Checks whether the Avatar is loading * @returns {Promise<boolean>} */ isLoading: () => getLoader().exists() }); }; exports.avatarUniDriverFactory = avatarUniDriverFactory; //# sourceMappingURL=Avatar.uni.driver.js.map