import { baseUniDriverFactory } from '../utils/test-utils/unidriver';
import { testkit as inputUniDriverFactory } from '../Input/Input.uni.driver';
import { labelledElementDriverFactory as labelledElementUniDriverFactory } from '../LabelledElement/LabelledElement.uni.driver';
import { DATA_HOOKS } from './InputWithLabel.constants';
export const inputWithLabelDriverFactory = (base) => {
    const inputWrapperSelector = `[data-hook="${DATA_HOOKS.input}"]`;
    const labelledElementSelector = `[data-hook="${DATA_HOOKS.labelledElement}"]`;
    const statusMessageSelector = `[data-hook="${DATA_HOOKS.errorMessage}"]`;
    // body is a required argument but this driver does not use methods that require it
    // @ts-expect-error
    const inputDriver = inputUniDriverFactory(base.$(inputWrapperSelector));
    const labelledElementDriver = labelledElementUniDriverFactory(base.$(labelledElementSelector));
    const errorMessageDriver = base.$(statusMessageSelector);
    return {
        ...baseUniDriverFactory(base),
        /** Gets the amount of rendered suffixes */
        getSuffixesCount: () => base.$$(`[data-hook="suffix-container"]`).count(),
        /** Returns true if an error status message exists */
        hasErrorMessage: () => errorMessageDriver.exists(),
        /** Gets the error status message */
        getErrorMessage: () => errorMessageDriver.text(),
        getValue: () => inputDriver.getValue(),
        clickInput: () => inputDriver.click(),
        enterText: (value) => inputDriver.enterText(value),
        getLabelText: () => labelledElementDriver.getLabelText(),
        isCustomInput: () => inputDriver.isCustomInput(),
        isFocusedStyle: () => inputDriver.isFocusedStyle(),
        getMaxLength: () => inputDriver.getMaxLength(),
        getPlaceholder: async () => {
            await inputDriver.click();
            const placeholder = inputDriver.getPlaceholder();
            await inputDriver.blur();
            return placeholder;
        },
    };
};
//# sourceMappingURL=InputWithLabel.uni.driver.js.map