import { baseUniDriverFactory, ReactBase } from '../utils/test-utils/unidriver';
import { enterRichTextValue, focusRichEditor, blurRichEditor, getContent, } from '../utils/test-utils/unidriver/DraftJS';
import { statusIndicatorDriverFactory } from '../StatusIndicator/StatusIndicator.uni.driver';
import { dataHooks } from './constants';
export const getPlaceholder = base => base.$('.public-DraftEditorPlaceholder-root');
export default (base, body) => {
    const getStatusIndicatorDriver = () => statusIndicatorDriverFactory(base.$(`[data-hook="${dataHooks.indicator}"]`), body);
    const baseUniDriver = baseUniDriverFactory(base);
    return {
        ...baseUniDriver,
        click: async () => {
            await baseUniDriver.click();
            await focusRichEditor(base);
        },
        isDisabled: async () => (await getContent(base).attr('contenteditable')) === 'false',
        getContent: () => getContent(base).text(),
        getPlaceholder: () => getPlaceholder(base).text(),
        enterText: text => enterRichTextValue(base, text),
        blur: () => blurRichEditor(base),
        focus: () => focusRichEditor(base),
        // Status
        /** Return true if there's a status */
        hasStatus: async (status) => {
            const statusIndicatorDriver = getStatusIndicatorDriver();
            if (await statusIndicatorDriver.exists()) {
                return status === (await statusIndicatorDriver.getStatus());
            }
            return false;
        },
        /** If there's a status message, returns its text value */
        getStatusMessage: async () => {
            const statusIndicatorDriver = getStatusIndicatorDriver();
            let tooltipText = null;
            if (await statusIndicatorDriver.hasMessage()) {
                tooltipText = await statusIndicatorDriver.getMessage();
            }
            return tooltipText;
        },
    };
};
//# sourceMappingURL=VariableInput.uni.driver.js.map