import { baseUniDriverFactory } from '../utils/test-utils/unidriver';
import { tooltipDriverFactory } from '../Tooltip/Tooltip.uni.driver';
const getTextElement = (element) => element.$(`[data-hook="loader-text"]`);
const getStatusIndicatorElement = (element) => element.$(`[data-hook="loader-status-indicator"]`);
export const loaderUniDriverFactory = (base, body) => {
    const tooltipSelector = '[data-hook="loader-tooltip"]';
    const tooltipTestkit = () => tooltipDriverFactory(base.$(tooltipSelector), body);
    return {
        ...baseUniDriverFactory(base),
        /** @deprecated Should be private */
        component: async () => base.getNative(),
        /** returns the loader color ('blue' or 'white') */
        getColor: async () => base.attr('data-color'),
        /** returns the element text */
        getText: async () => getTextElement(base).text(),
        /** true if the element has text */
        hasText: async () => getTextElement(base).exists(),
        /** true if the status indicator is rendered */
        statusIndicatorExists: async () => getStatusIndicatorElement(base).exists(),
        /** true when using the large loader */
        isLarge: async () => (await base.attr('data-size')) === 'large',
        /** true when using the medium loader */
        isMedium: async () => (await base.attr('data-size')) === 'medium',
        /** true when using the small loader */
        isSmall: async () => (await base.attr('data-size')) === 'small',
        /** true when using the tiny loader */
        isTiny: async () => (await base.attr('data-size')) === 'tiny',
        /** true when loader is in loading status */
        isLoading: async () => (await base.attr('data-status')) === 'loading',
        /** true when loader is in loading-with-errors status */
        isLoadingWithErrors: async () => (await base.attr('data-status')) === 'loadingWithErrors',
        /** true when loader is in error status */
        isError: async () => (await base.attr('data-status')) === 'error',
        /** true when loader is in success status */
        isSuccess: async () => (await base.attr('data-status')) === 'success',
        /** trigger the tooltip and returns the value of the tooltip message (async function) */
        getStatusMessage: async () => {
            const tooltipDriver = tooltipTestkit();
            await tooltipDriver.mouseEnter();
            return tooltipDriver.getTooltipText();
        },
    };
};
//# sourceMappingURL=Loader.uni.driver.js.map