"use strict";
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());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const react_core_1 = require("@patternfly/react-core");
const react_1 = require("@testing-library/react");
const ChatbotHeaderSelectorDropdown_1 = require("./ChatbotHeaderSelectorDropdown");
require("@testing-library/jest-dom");
describe('ChatbotHeaderSelectorDropdown', () => {
    const dropdownItems = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_core_1.DropdownItem, { children: "Option 1" }), (0, jsx_runtime_1.jsx)(react_core_1.DropdownItem, { children: "Option 2" }), (0, jsx_runtime_1.jsx)(react_core_1.DropdownItem, { children: "Option 3" })] }));
    it('should render ChatbotHeaderSelectorDropdown', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(ChatbotHeaderSelectorDropdown_1.ChatbotHeaderSelectorDropdown, { value: "Option 1", children: dropdownItems }));
        expect(react_1.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 } = (0, react_1.render)((0, jsx_runtime_1.jsx)(ChatbotHeaderSelectorDropdown_1.ChatbotHeaderSelectorDropdown, { value: "Option 1", className: "custom-header-selector-dropdown", onSelect: onSelect, children: dropdownItems }));
        (0, react_1.act)(() => {
            react_1.fireEvent.click(react_1.screen.getByRole('button', { name: /Select model/i }));
        });
        yield (0, react_1.waitFor)(() => {
            expect(container.querySelector('.custom-header-selector-dropdown')).toBeTruthy();
            expect(react_1.screen.getByText('Option 3'));
            react_1.fireEvent.click(react_1.screen.getByText('Option 3'));
            expect(onSelect).toHaveBeenCalled();
        });
    }));
    it('should handle isCompact', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(ChatbotHeaderSelectorDropdown_1.ChatbotHeaderSelectorDropdown, { value: "Option 1", isCompact: true, children: dropdownItems }));
        expect(react_1.screen.getByRole('button', { name: /Select model/i })).toHaveClass('pf-m-compact');
    });
    it('should handle toggleProps', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(ChatbotHeaderSelectorDropdown_1.ChatbotHeaderSelectorDropdown, { value: "Option 1", toggleProps: { isDisabled: true }, children: dropdownItems }));
        expect(react_1.screen.getByRole('button', { name: /Select model/i })).toBeDisabled();
    });
});
