var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { DropdownItem } from '@patternfly/react-core';
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
import { ChatbotHeaderOptionsDropdown } from './ChatbotHeaderOptionsDropdown';
import '@testing-library/jest-dom';
describe('ChatbotHeaderOptionsDropdown', () => {
    const dropdownItems = (_jsxs(_Fragment, { children: [_jsx(DropdownItem, { children: "Option 1" }), _jsx(DropdownItem, { children: "Option 2" }), _jsx(DropdownItem, { children: "Option 3" })] }));
    it('should render ChatbotHeaderOptionsDropdown', () => {
        render(_jsx(ChatbotHeaderOptionsDropdown, { children: dropdownItems }));
        expect(screen.getByRole('button', { name: 'Chatbot options' })).toBeTruthy();
    });
    it('should call onselect handler when a dropdown item is clicked', () => __awaiter(void 0, void 0, void 0, function* () {
        const onSelect = jest.fn();
        const { container } = render(_jsx(ChatbotHeaderOptionsDropdown, { className: "custom-header-options-dropdown", onSelect: onSelect, children: dropdownItems }));
        act(() => {
            fireEvent.click(screen.getByRole('button', { name: 'Chatbot options' }));
        });
        yield waitFor(() => {
            expect(container.querySelector('.custom-header-options-dropdown')).toBeTruthy();
            expect(screen.getByText('Option 1'));
            expect(screen.getByText('Option 2'));
            expect(screen.getByText('Option 3'));
            fireEvent.click(screen.getByText('Option 3'));
            expect(onSelect).toHaveBeenCalled();
        });
    }));
    it('should handle isCompact', () => {
        render(_jsx(ChatbotHeaderOptionsDropdown, { isCompact: true, children: dropdownItems }));
        expect(screen.getByRole('button', { name: 'Chatbot options' })).toHaveClass('pf-m-compact');
    });
    it('should handle toggleProps', () => {
        render(_jsx(ChatbotHeaderOptionsDropdown, { isCompact: true, toggleProps: { isDisabled: true }, children: dropdownItems }));
        expect(screen.getByRole('button', { name: /Chatbot options/i })).toBeDisabled();
    });
});
