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 React from 'react';
import { DropdownItem } from '@patternfly/react-core';
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
import { ChatbotHeaderSelectorDropdown } from './ChatbotHeaderSelectorDropdown';
describe('ChatbotHeaderSelectorDropdown', () => {
    const dropdownItems = (React.createElement(React.Fragment, null,
        React.createElement(DropdownItem, null, "Option 1"),
        React.createElement(DropdownItem, null, "Option 2"),
        React.createElement(DropdownItem, null, "Option 3")));
    it('should render ChatbotHeaderSelectorDropdown', () => {
        render(React.createElement(ChatbotHeaderSelectorDropdown, { value: "Option 1" }, dropdownItems));
        expect(screen.getByRole('button', { name: /Select model/i })).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(React.createElement(ChatbotHeaderSelectorDropdown, { value: "Option 1", className: "custom-header-selector-dropdown", onSelect: onSelect }, dropdownItems));
        act(() => {
            fireEvent.click(screen.getByRole('button', { name: /Select model/i }));
        });
        yield waitFor(() => {
            expect(container.querySelector('.custom-header-selector-dropdown')).toBeTruthy();
            expect(screen.getByText('Option 3'));
            fireEvent.click(screen.getByText('Option 3'));
            expect(onSelect).toHaveBeenCalled();
        });
    }));
});
