"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());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const react_core_1 = require("@patternfly/react-core");
const react_2 = require("@testing-library/react");
const ChatbotHeaderSelectorDropdown_1 = require("./ChatbotHeaderSelectorDropdown");
describe('ChatbotHeaderSelectorDropdown', () => {
    const dropdownItems = (react_1.default.createElement(react_1.default.Fragment, null,
        react_1.default.createElement(react_core_1.DropdownItem, null, "Option 1"),
        react_1.default.createElement(react_core_1.DropdownItem, null, "Option 2"),
        react_1.default.createElement(react_core_1.DropdownItem, null, "Option 3")));
    it('should render ChatbotHeaderSelectorDropdown', () => {
        (0, react_2.render)(react_1.default.createElement(ChatbotHeaderSelectorDropdown_1.ChatbotHeaderSelectorDropdown, { value: "Option 1" }, dropdownItems));
        expect(react_2.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_2.render)(react_1.default.createElement(ChatbotHeaderSelectorDropdown_1.ChatbotHeaderSelectorDropdown, { value: "Option 1", className: "custom-header-selector-dropdown", onSelect: onSelect }, dropdownItems));
        (0, react_2.act)(() => {
            react_2.fireEvent.click(react_2.screen.getByRole('button', { name: /Select model/i }));
        });
        yield (0, react_2.waitFor)(() => {
            expect(container.querySelector('.custom-header-selector-dropdown')).toBeTruthy();
            expect(react_2.screen.getByText('Option 3'));
            react_2.fireEvent.click(react_2.screen.getByText('Option 3'));
            expect(onSelect).toHaveBeenCalled();
        });
    }));
});
