import * as __WEBPACK_EXTERNAL_MODULE__testing_library_react__ from "@testing-library/react";
import * as __WEBPACK_EXTERNAL_MODULE__testing_library_user_event__ from "@testing-library/user-event";
import * as __WEBPACK_EXTERNAL_MODULE__Popover_mjs__ from "./Popover.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__PopoverContent_mjs__ from "./PopoverContent.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__chakra_ui_react__ from "@chakra-ui/react";
describe('Popover', ()=>{
    test('should render Popover items with title and content when hovering over the trigger', async ()=>{
        const user = __WEBPACK_EXTERNAL_MODULE__testing_library_user_event__["default"].setup();
        const { getByText, getByLabelText, findByText } = (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__Popover_mjs__["default"], {
            title: "Popover title",
            content: "This is popover content"
        }, /*#__PURE__*/ React.createElement("button", null, "Trigger")));
        await user.hover(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByRole('button', {
            name: /trigger/i
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(getByText(/popover title/i)).toBeVisible();
            expect(getByText(/popover content/i)).toBeVisible();
            expect(getByLabelText(/close/i)).toBeVisible();
        });
    });
    test('should render Popover items with title and content after clicking trigger', async ()=>{
        const user = __WEBPACK_EXTERNAL_MODULE__testing_library_user_event__["default"].setup();
        const { getByText, getByLabelText, findByText } = (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__Popover_mjs__["default"], {
            title: "Popover title",
            content: "This is popover content",
            trigger: "click"
        }, /*#__PURE__*/ React.createElement("button", null, "Trigger")));
        const triggerButton = await findByText(/trigger/i);
        await user.click(triggerButton);
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(getByText(/popover title/i)).toBeVisible();
            expect(getByText(/popover content/i)).toBeVisible();
            expect(getByLabelText(/close/i)).toBeVisible();
        });
    });
    test('should render Popover without title and close button', async ()=>{
        const user = __WEBPACK_EXTERNAL_MODULE__testing_library_user_event__["default"].setup();
        const { getByText, getByLabelText, findByText, queryByText, queryByLabelText } = (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__Popover_mjs__["default"], {
            content: "This is popover content",
            hideCloseButton: true
        }, /*#__PURE__*/ React.createElement("button", null, "Trigger")));
        const triggerButton = await findByText(/trigger/i);
        await user.tab();
        await user.hover(triggerButton);
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(getByText(/popover content/i)).toBeVisible();
            expect(queryByText(/popover title/i)).not.toBeInTheDocument();
            expect(queryByLabelText(/close/i)).not.toBeInTheDocument();
        });
    });
    test('should render Popover title and content using compound components', async ()=>{
        const user = __WEBPACK_EXTERNAL_MODULE__testing_library_user_event__["default"].setup();
        const { getByText, queryByLabelText } = (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__Popover_mjs__["default"], null, /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.PopoverTrigger, null, /*#__PURE__*/ React.createElement("button", null, "Trigger")), /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__PopoverContent_mjs__["default"], null, /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.PopoverHeader, null, "Popover header"), /*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.PopoverBody, null, "Popover body"))));
        await user.tab();
        await user.hover(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByRole('button', {
            name: /trigger/i
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(getByText(/popover body/i)).toBeVisible();
            expect(getByText(/popover header/i)).toBeVisible();
            expect(queryByLabelText(/close/i)).not.toBeInTheDocument();
        });
    });
});
