"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");
const user_event_1 = __importDefault(require("@testing-library/user-event"));
require("@testing-library/jest-dom");
const QuickResponse_1 = __importDefault(require("./QuickResponse"));
test('Renders with quick responses', () => {
    const quickResponses = [
        { id: '1', content: 'Response 1' },
        { id: '2', content: 'Response 2' },
        { id: '3', content: 'Response 3' }
    ];
    (0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses }));
    expect(react_1.screen.getByText('Response 1')).toBeVisible();
    expect(react_1.screen.getByText('Response 2')).toBeVisible();
    expect(react_1.screen.getByText('Response 3')).toBeVisible();
});
test('Renders with compact styling', () => {
    const quickResponses = [{ id: '1', content: 'Compact response' }];
    (0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses, isCompact: true }));
    expect(react_1.screen.getByText('Compact response').closest('.pf-v6-c-label')).toHaveClass('pf-m-compact');
});
test('Renders with custom className on response', () => {
    const quickResponses = [{ id: '1', content: 'Custom class response', className: 'custom-response-class' }];
    (0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses }));
    expect(react_1.screen.getByText('Custom class response').closest('.pf-v6-c-label')).toHaveClass('custom-response-class');
});
test('Renders with custom container className', () => {
    const quickResponses = [
        { id: '1', content: 'Response 1' },
        { id: '2', content: 'Response 2' }
    ];
    (0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses, quickResponseContainerProps: { className: 'custom-container-class' } }));
    expect(react_1.screen.getByText('Response 1').closest('.pf-v6-c-label-group')).toHaveClass('custom-container-class');
});
test('Spreads additional custom container props', () => {
    const quickResponses = [
        { id: '1', content: 'Response 1' },
        { id: '2', content: 'Response 2' }
    ];
    (0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses, quickResponseContainerProps: { id: 'custom-container-id' } }));
    expect(react_1.screen.getByText('Response 1').closest('.pf-v6-c-label-group__list')).toHaveAttribute('id', 'custom-container-id');
});
test('Renders with pf-chatbot__message-quick-response--selected class after click', () => __awaiter(void 0, void 0, void 0, function* () {
    const user = user_event_1.default.setup();
    const quickResponses = [
        { id: '1', content: 'Response 1' },
        { id: '2', content: 'Response 2' }
    ];
    (0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses }));
    yield user.click(react_1.screen.getByText('Response 1'));
    expect(react_1.screen.getByText('Response 1').closest('.pf-v6-c-label')).toHaveClass('pf-chatbot__message-quick-response--selected');
}));
test('Does not calls onClick handler when not passed', () => __awaiter(void 0, void 0, void 0, function* () {
    const user = user_event_1.default.setup();
    const handleClick = jest.fn();
    const quickResponses = [{ id: '1', content: 'Clickable response' }];
    (0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses }));
    yield user.click(react_1.screen.getByText('Clickable response'));
    expect(handleClick).not.toHaveBeenCalled();
}));
test('Calls onClick handler when passed', () => __awaiter(void 0, void 0, void 0, function* () {
    const user = user_event_1.default.setup();
    const handleClick = jest.fn();
    const quickResponses = [{ id: '1', content: 'Clickable response', onClick: handleClick }];
    (0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses }));
    yield user.click(react_1.screen.getByText('Clickable response'));
    expect(handleClick).toHaveBeenCalled();
}));
test('Does not call onSelect when not passed', () => __awaiter(void 0, void 0, void 0, function* () {
    const user = user_event_1.default.setup();
    const handleSelect = jest.fn();
    const quickResponses = [
        { id: '1', content: 'Response 1' },
        { id: '2', content: 'Response 2' }
    ];
    (0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses }));
    yield user.click(react_1.screen.getByText('Response 2'));
    expect(handleSelect).not.toHaveBeenCalled();
}));
test('Calls onSelect when passed', () => __awaiter(void 0, void 0, void 0, function* () {
    const user = user_event_1.default.setup();
    const handleSelect = jest.fn();
    const quickResponses = [
        { id: '1', content: 'Response 1' },
        { id: '2', content: 'Response 2' }
    ];
    (0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses, onSelect: handleSelect }));
    yield user.click(react_1.screen.getByText('Response 2'));
    expect(handleSelect).toHaveBeenCalledWith('2');
}));
test('Spreads additional response props', () => {
    const quickResponses = [{ id: '1', content: 'Response with props', isCompact: true, 'aria-label': 'Test label' }];
    (0, react_1.render)((0, jsx_runtime_1.jsx)(QuickResponse_1.default, { quickResponses: quickResponses }));
    expect(react_1.screen.getByText('Response with props').closest('.pf-v6-c-label')).toHaveAttribute('aria-label', 'Test label');
});
