import { screen, within } from "@testing-library/dom";
/**
 * @example Simple Example
 * ```tsx
 * import {
 *   getSelectTestElements,
 *   screen,
 *   rmdRender,
 *   userEvent,
 * } from "@react-md/core/test-utils";
 *
 * it("should be able to verify the display value", async () => {
 *   const user = userEvent.setup();
 *   rmdRender(<SimpleSelect />);
 *
 *   const { select, selectInput, selectedOption } = getSelectTestElements({
 *     name: "Label",
 *   });
 *   // this isn't required, but added to show what element this is
 *   expect(selectedOption).toHaveClass("rmd-selected-option");
 *
 *   // there is currently no selected value
 *   expect(selectedOption).toHaveTextContent("");
 *
 *   await user.click(select);
 *   await user.click(screen.getByRole("option", { name: "Option 1" }));
 *   expect(selectInput).toHaveValue("a");
 *   expect(selectedOption).toHaveTextContent("Option 1");
 * });
 * ```
 *
 * @since 6.0.0
 */ export function getSelectTestElements(options) {
    const { container = screen, ...byRoleOptions } = options;
    const select = container.getByRole("combobox", byRoleOptions);
    const selectInput = within(select).getByRole("textbox", {
        hidden: true
    });
    const selectedOption = select.firstElementChild;
    if (!(selectedOption instanceof HTMLDivElement)) {
        throw new Error("Unable to find the `Select` selected option element");
    }
    return {
        select,
        selectInput,
        selectedOption
    };
}
/**
 * @see {@link getSelectTestElements}
 * @since 6.0.0
 */ export async function findSelectTestElements(options) {
    const { container = screen, ...byRoleOptions } = options;
    const select = await container.findByRole("combobox", byRoleOptions);
    const selectInput = await within(select).findByRole("textbox", {
        hidden: true
    });
    const selectedOption = select.firstElementChild;
    if (!(selectedOption instanceof HTMLDivElement)) {
        throw new Error("Unable to find the `Select` selected option element");
    }
    return {
        select,
        selectInput,
        selectedOption
    };
}

//# sourceMappingURL=select.js.map