import { baseUniDriverFactory } from '../utils/test-utils/unidriver';
import { DATA_HOOKS } from './TableListItem.constants';
import { checkboxUniDriverFactory } from '../Checkbox/Checkbox.uni.driver';
import { dragHandleUniDriverFactory } from '../DragHandle/DragHandle.uni.driver';
export const tableListItemDriverFactory = (base, body) => {
    const getColumnAt = (index) => base.$$(`[data-hook="${DATA_HOOKS.tableListItemValue}"]`).get(index);
    const getCheckboxDriver = () => checkboxUniDriverFactory(base.$(`[data-hook="${DATA_HOOKS.tableListItemCheckbox}"]`), body);
    const getColumnTextAt = async (index) => {
        const column = await getColumnAt(index);
        return column.text();
    };
    const dragHandle = dragHandleUniDriverFactory(base.$(`[data-hook="${DATA_HOOKS.tableListItemDragHandle}"]`), body);
    const getExpandHandle = () => {
        return {
            exists: () => base
                .$(`[data-hook="${DATA_HOOKS.tableListItemExpandHandleContainer}"]`)
                .exists(),
            click: () => base
                .$(`[data-hook="${DATA_HOOKS.tableListItemExpandHandleContainer}"]`)
                .click(),
        };
    };
    return {
        ...baseUniDriverFactory(base),
        /** Get column alternative text. */
        getColumnTextAt,
        /** Defines if checkbox exists. */
        isCheckboxExists: () => {
            const driver = getCheckboxDriver();
            return driver.exists();
        },
        /** Defines if checkbox is checked. */
        isCheckboxChecked: () => {
            const driver = getCheckboxDriver();
            return driver.isChecked();
        },
        /** Defines if checkbox is disabled. */
        isCheckboxDisabled: () => {
            const driver = getCheckboxDriver();
            return driver.isDisabled();
        },
        /** Defines if checkbox tooltip is enabled. */
        isCheckboxTooltipEnabled: () => getCheckboxDriver().isTooltipEnabled(),
        /** Defines if drag handle tooltip is enabled. */
        isDragHandleTooltipEnabled: () => dragHandle.isTooltipEnabled(),
        /** Defines if expand handle exists. */
        expandHandleExists: () => getExpandHandle().exists(),
        /** Trigger checkbox toggle. */
        toggleCheckbox: () => {
            const driver = getCheckboxDriver();
            return driver.click();
        },
        /** Trigger expand toggle. */
        toggleExpandHandle: () => getExpandHandle().click(),
        /** Trigger hover on a drag handle. */
        hoverDragHandle: () => dragHandle.hover(),
        /** Defines if drag handle is disabled. */
        getDragHandleDisabled: () => dragHandle.getDisabled(),
        /** Get the content of checkbox tooltip. */
        getCheckboxTooltipContent: () => getCheckboxDriver().getTooltipContent(),
        /** Get the content of drag handle tooltip. */
        getDragHandleTooltipContent: () => dragHandle.getTooltipContent(),
    };
};
//# sourceMappingURL=TableListItem.uni.driver.js.map