import { baseUniDriverFactory, findByHook, } from '../utils/test-utils/unidriver';
import { tooltipDriverFactory } from '../Tooltip/Tooltip.uni.driver';
import { dataHooks } from './constants';
export const checkToggleDriverFactory = (base, body) => {
    const getTooltipDriver = () => tooltipDriverFactory(findByHook(base, dataHooks.tooltip), body);
    return {
        ...baseUniDriverFactory(base),
        // Checks whether CheckToggle is checked
        isChecked: () => findByHook(base, dataHooks.toggle).prop('checked'),
        // Clicks on the element
        click: async () => {
            const input = await findByHook(base, dataHooks.toggle);
            const isDisabled = await input.prop('disabled');
            // In order to simulate a real user event, we need to check if the input is disabled before clicking.
            if (!isDisabled)
                await input.click();
        },
        //  Gets the tooltip content, throws an error if content is not provided.
        getTooltipContent: async () => {
            const tooltipDriver = getTooltipDriver();
            if (await tooltipDriver.exists()) {
                await tooltipDriver.mouseEnter();
                const text = await tooltipDriver.getTooltipText();
                if (typeof text === 'string') {
                    return text;
                }
            }
            throw new Error(`Message was not provided`);
        },
    };
};
//# sourceMappingURL=CheckToggle.uni.driver.js.map