import { dropdownBaseDriverFactory } from '../DropdownBase/DropdownBase.uni.driver';
import { dropdownLayoutDriverFactory } from '../DropdownLayout/DropdownLayout.uni.driver';
import { popoverNextUniDriverFactory } from '../PopoverNext/PopoverNext.uni.driver';
import { baseUniDriverFactory } from '../utils/test-utils/unidriver';
export const PopoverMenuDriver = (base, body) => {
    const dropdownBaseTestkit = dropdownBaseDriverFactory(base, body);
    const getContentElement = async () => popoverNextUniDriverFactory(base, body).getContentElementUniDriver();
    const createDropdownLayoutDriver = async () => dropdownLayoutDriverFactory((await getContentElement()).$(`[data-hook="dropdown-base-dropdownlayout"]`), body);
    return {
        ...baseUniDriverFactory(base),
        /** Returns true of popoverMenu exists */
        exists: () => dropdownBaseTestkit.exists(),
        /** Returns trigger element */
        getTriggerElement: (dataHook) => base.$(`[data-hook="${dataHook}"]`),
        /** Select a specific option by its index (requires the menu to be opened) */
        clickAtChild: (index) => dropdownBaseTestkit.selectOption(index),
        /** Select a specific option by its data-hook (requires the menu to be opened) */
        clickAtChildByDataHook: (dataHook) => dropdownBaseTestkit.selectOptionByDataHook(dataHook),
        /** Return true if the menu is opened */
        isMenuOpen: () => dropdownBaseTestkit.isDropdownShown(),
        /** Returns children count */
        childrenCount: () => dropdownBaseTestkit.optionsCount(),
        /** Returns text of <PopoverMenu.MenuItem/> of a specific index */
        itemContentAt: async (index) => {
            const dropdownLayoutDriver = await createDropdownLayoutDriver();
            const optionsDrivers = await dropdownLayoutDriver.options();
            return await optionsDrivers[index].content();
        },
        isListItemFocused: async (position) => createDropdownLayoutDriver().then(tsk => tsk.isListItemFocused(position)),
        /** Returns the content element (`<Popover.Content/>`) */
        getContentElement,
    };
};
export default PopoverMenuDriver;
//# sourceMappingURL=PopoverMenu.uni.driver.js.map