"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 jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("@testing-library/react");
require("@testing-library/jest-dom");
const user_event_1 = __importDefault(require("@testing-library/user-event"));
const ChatbotToggle_1 = __importDefault(require("./ChatbotToggle"));
describe('ChatbotToggle', () => {
    it('should render tooltipLabel correctly', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(ChatbotToggle_1.default, { tooltipLabel: "Tooltip" }));
        yield user_event_1.default.click(react_1.screen.getByRole('button', { name: /Tooltip toggle/i }));
        expect(react_1.screen.getByRole('tooltip', { name: /Tooltip/i })).toBeTruthy();
    }));
    it('should render toggleButtonLabel correctly', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(ChatbotToggle_1.default, { tooltipLabel: "Chatbot", toggleButtonLabel: "Button" }));
        expect(react_1.screen.getByRole('button', { name: /Button/i })).toBeTruthy();
    }));
    it('should call onToggleChatbot when clicked', () => __awaiter(void 0, void 0, void 0, function* () {
        const spy = jest.fn();
        (0, react_1.render)((0, jsx_runtime_1.jsx)(ChatbotToggle_1.default, { tooltipLabel: "Chatbot", onToggleChatbot: spy }));
        yield user_event_1.default.click(react_1.screen.getByRole('button'));
        expect(spy).toHaveBeenCalledTimes(1);
    }));
    it('should handle isChatbotVisible correctly when true', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(ChatbotToggle_1.default, { tooltipLabel: "Chatbot", isChatbotVisible: true, openIconTestId: "Open" }));
        expect(react_1.screen.getByRole('button')).toHaveClass('pf-chatbot__button');
        expect(react_1.screen.getByRole('button')).toHaveClass('pf-chatbot__button--active');
        expect(react_1.screen.getByRole('button')).toHaveAttribute('aria-expanded', 'true');
        expect(react_1.screen.getByTestId('Open')).toBeTruthy();
    });
    it('should handle isChatbotVisible correctly when false', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(ChatbotToggle_1.default, { tooltipLabel: "Chatbot", isChatbotVisible: false, openIconTestId: "Open" }));
        expect(react_1.screen.getByRole('button')).toHaveClass('pf-chatbot__button');
        expect(react_1.screen.getByRole('button')).not.toHaveClass('pf-chatbot__button--active');
        expect(react_1.screen.getByRole('button')).toHaveAttribute('aria-expanded', 'false');
        expect(react_1.screen.queryByTestId('Open')).toBeFalsy();
    });
    it('should handle isRound correctly', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(ChatbotToggle_1.default, { tooltipLabel: "Chatbot", isRound: true }));
        expect(react_1.screen.getByRole('button')).toHaveClass('pf-chatbot__button');
        expect(react_1.screen.getByRole('button')).toHaveClass('pf-chatbot__button--round');
    });
    it('should handle className correctly', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(ChatbotToggle_1.default, { tooltipLabel: "Chatbot", className: "test" }));
        expect(react_1.screen.getByRole('button')).toHaveClass('pf-chatbot__button');
        expect(react_1.screen.getByRole('button')).toHaveClass('test');
    });
});
