import { baseUniDriverFactory, findByHook, } from '../utils/test-utils/unidriver';
import { dataHooks, getCompoundDataHook } from './constants';
import { sidebarItemButtonNextDriverFactory } from '../SidebarItemNext/SidebarItemButtonNext.uni.driver';
export const sidebarSubMenuNextDriverFactory = (base, body) => {
    const findByHookWithin = async (dataHook) => findByHook(base, getCompoundDataHook(await base.attr('data-hook'), dataHook));
    return {
        ...baseUniDriverFactory(base, body),
        /**
         * Returns true if submenu is expanded
         * @returns {Promise<boolean>}
         */
        isExpanded: async () => (await base.attr('data-open')) === 'true',
        /**
         * Clicks on the sidebar submenu
         * @returns {Promise<any>}
         */
        click: async () => (await findByHookWithin(dataHooks.sidebarItem)).click(),
        /**
         * Triggers a mouseEnter event
         * @return {Promise<void>}
         */
        triggerMouseEnter: async () => {
            const trigger = await findByHookWithin(dataHooks.submenuPopover);
            // We don't render the popover trigger if the submenu is empty, but we
            // still want to expose the `triggerMouseEnter` for backwards
            // compatibility.
            if (await trigger.exists()) {
                await trigger.hover();
            }
        },
        /**
         * Returns if the sidebar submenu is disabled
         * @returns {Promise<boolean>}
         */
        isDisabled: async () => {
            const button = await findByHookWithin(dataHooks.sidebarItem);
            const buttonDriver = sidebarItemButtonNextDriverFactory(button);
            return await buttonDriver.isDisabled();
        },
        /**
         * Returns the submenu title
         * @returns {Promise<any>}
         */
        getTitle: async (dataHook) => await findByHook(base, dataHook),
        /**
         * Returns the submenu title text
         * @returns {Promise<string>}
         */
        getTitleText: async () => (await findByHookWithin(dataHooks.sidebarItem)).text(),
        isQuickNavOpen: async () => (await base.attr('data-quick-nav-open')) === 'true',
    };
};
//# sourceMappingURL=SidebarSubMenuNext.uni.driver.js.map