import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import ToolResponse from './ToolResponse';
describe('ToolResponse', () => {
    const defaultProps = {
        toggleContent: 'Tool response: toolName',
        cardTitle: 'Title',
        cardBody: 'Body'
    };
    it('should render with required props only', () => {
        render(_jsx(ToolResponse, Object.assign({}, defaultProps)));
        expect(screen.getByText('Title')).toBeTruthy();
        expect(screen.getByText('Body')).toBeTruthy();
        expect(screen.getByText('Tool response: toolName')).toBeTruthy();
    });
    it('should render subheading when provided', () => {
        const subheading = 'Tool execution result';
        render(_jsx(ToolResponse, Object.assign({}, defaultProps, { subheading: subheading })));
        expect(screen.getByText(subheading)).toBeTruthy();
    });
    it('should render body content when provided', () => {
        const body = 'This is the tool response body content';
        render(_jsx(ToolResponse, Object.assign({}, defaultProps, { body: body })));
        expect(screen.getByText(body)).toBeTruthy();
    });
    it('should render with complex content including React elements', () => {
        const body = (_jsxs("div", { children: [_jsx("p", { children: "Complex body content" }), _jsxs("ul", { children: [_jsx("li", { children: "Item 1" }), _jsx("li", { children: "Item 2" })] })] }));
        const cardTitle = _jsx("strong", { children: "API Response" });
        const cardBody = (_jsx("div", { children: _jsx("code", { children: "{ status: 'success' }" }) }));
        render(_jsx(ToolResponse, Object.assign({}, defaultProps, { body: body, cardTitle: cardTitle, cardBody: cardBody })));
        expect(screen.getByText('Complex body content')).toBeTruthy();
        expect(screen.getByText('Item 1')).toBeTruthy();
        expect(screen.getByText('Item 2')).toBeTruthy();
        expect(screen.getByText('API Response')).toBeTruthy();
        expect(screen.getByText("{ status: 'success' }")).toBeTruthy();
    });
    it('should apply custom className from cardProps', () => {
        const { container } = render(_jsx(ToolResponse, Object.assign({}, defaultProps, { cardProps: { className: 'custom-tool-response-class' } })));
        expect(container.querySelector('.custom-tool-response-class')).toBeTruthy();
    });
    it('should pass through expandableSectionProps', () => {
        render(_jsx(ToolResponse, Object.assign({}, defaultProps, { expandableSectionProps: { className: 'custom-expandable-class' } })));
        expect(document.querySelector('.custom-expandable-class')).toBeTruthy();
    });
    it('should pass through toolResponseCardProps', () => {
        render(_jsx(ToolResponse, Object.assign({}, defaultProps, { toolResponseCardProps: { className: 'custom-card-class' } })));
        expect(document.querySelector('.custom-card-class')).toBeTruthy();
    });
    it('should not render subheading span when subheading is not provided', () => {
        const { container } = render(_jsx(ToolResponse, Object.assign({}, defaultProps)));
        const subheadingContainer = container.querySelector('.pf-chatbot__tool-response-subheading');
        expect(subheadingContainer).toBeFalsy();
    });
    it('should not render card when cardTitle and cardBody are not provided', () => {
        const { container } = render(_jsx(ToolResponse, Object.assign({}, defaultProps, { cardTitle: undefined, cardBody: undefined })));
        expect(container.querySelector('.pf-chatbot__tool-response-card')).toBeFalsy();
    });
    it('should render card when only cardTitle is provided', () => {
        const { container } = render(_jsx(ToolResponse, Object.assign({}, defaultProps, { cardBody: undefined })));
        expect(container.querySelector('.pf-chatbot__tool-response-card')).toBeTruthy();
    });
    it('should render card when only cardBody is provided', () => {
        const { container } = render(_jsx(ToolResponse, Object.assign({}, defaultProps, { cardTitle: undefined })));
        expect(container.querySelector('.pf-chatbot__tool-response-card')).toBeTruthy();
    });
    it('should render divider when cardBody and cardTitle are provided', () => {
        const { container } = render(_jsx(ToolResponse, Object.assign({}, defaultProps)));
        expect(container.querySelector('.pf-v6-c-divider')).toBeTruthy();
    });
    it('should not render divider when only cardBody is provided', () => {
        const { container } = render(_jsx(ToolResponse, Object.assign({}, defaultProps, { cardTitle: undefined })));
        expect(container.querySelector('.pf-v6-c-divider')).toBeFalsy();
    });
    it('should not render divider when only cardTitle is provided', () => {
        const { container } = render(_jsx(ToolResponse, Object.assign({}, defaultProps, { cardBody: undefined })));
        expect(container.querySelector('.pf-v6-c-divider')).toBeFalsy();
    });
});
