UNPKG

wix-style-react

Version:
83 lines (67 loc) 2.3 kB
import { findByHook, resolveIn, isClassExists } from '../../test/utils'; import tooltipDriverFactory from '../Tooltip/Tooltip.driver'; var getTextElement = function getTextElement(element) { return element.querySelector('[data-hook="loader-text"]'); }; var loaderDriverFactory = function loaderDriverFactory(_ref) { var element = _ref.element; return { component: function component() { return element; }, exists: function exists() { return !!element; }, /** returns the loader color ('blue' or 'white') */ getColor: function getColor() { return isClassExists(element, 'blue') ? 'blue' : 'white'; }, /** returns the element text */ getText: function getText() { return getTextElement(element).textContent; }, /** true if the element has text */ hasText: function hasText() { return !!getTextElement(element); }, /** true when using the large loader */ isLarge: function isLarge() { return isClassExists(element, 'large'); }, /** true when using the medium loader */ isMedium: function isMedium() { return isClassExists(element, 'medium'); }, /** true when using the small loader */ isSmall: function isSmall() { return isClassExists(element, 'small'); }, /** true when using the tiny loader */ isTiny: function isTiny() { return isClassExists(element, 'tiny'); }, /** true when loader is in loading status */ isLoading: function isLoading() { return isClassExists(element, 'loading'); }, /** true when loader is in error status */ isError: function isError() { return isClassExists(element, 'error'); }, /** true when loader is in success status */ isSuccess: function isSuccess() { return isClassExists(element, 'success'); }, /** trigger the tooltip and returns the value of the tooltip message (async function) */ getStatusMessage: function getStatusMessage() { var tooltipDriver = tooltipDriverFactory({ element: findByHook(element, 'loader-tooltip') }); tooltipDriver.mouseEnter(); return resolveIn(500).then(function () { return tooltipDriver.getContent(); }); } }; }; export default loaderDriverFactory;