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());
    });
};
import { jsx as _jsx } from "react/jsx-runtime";
import { fireEvent, render, screen, within } from '@testing-library/react';
import '@testing-library/jest-dom';
import { PreviewAttachment } from './PreviewAttachment';
describe('PreviewAttachment', () => {
    it('should render PreviewAttachment', () => {
        render(_jsx(PreviewAttachment, { code: "Hello world", fileName: "greetings.txt", isModalOpen: true, onEdit: jest.fn(), handleModalToggle: jest.fn() }));
        expect(screen.getByText('Preview attachment')).toBeTruthy();
        expect(screen.getByText('greetings')).toBeTruthy();
        expect(screen.getAllByText('TEXT')).toBeTruthy();
    });
    it('should call onEdit handler when edit button is pressed', () => {
        const onEdit = jest.fn();
        render(_jsx(PreviewAttachment, { code: "Hello world", fileName: "greetings.txt", isModalOpen: true, onEdit: onEdit, handleModalToggle: jest.fn() }));
        fireEvent.click(screen.getByText('Edit'));
        expect(onEdit).toHaveBeenCalled();
    });
    it('should call onDismiss handler when dismiss button is pressed', () => {
        const onDismiss = jest.fn();
        render(_jsx(PreviewAttachment, { code: "Hello world", fileName: "greetings.txt", isModalOpen: true, onEdit: jest.fn(), handleModalToggle: onDismiss }));
        fireEvent.click(screen.getByText('Dismiss'));
        expect(onDismiss).toHaveBeenCalled();
    });
    it('should render custom button text for footer actions buttons', () => {
        render(_jsx(PreviewAttachment, { code: "Hello world", fileName: "greetings.txt", isModalOpen: true, onEdit: jest.fn(), handleModalToggle: jest.fn(), primaryActionButtonText: "Edit", secondaryActionButtonText: "Close" }));
        screen.getByText('Edit');
        screen.getByText('Close');
    });
    it('should render PreviewAttachment with custom classNames', () => __awaiter(void 0, void 0, void 0, function* () {
        render(_jsx(PreviewAttachment, { code: "Hello world", fileName: "greetings.txt", isModalOpen: true, onEdit: jest.fn(), handleModalToggle: jest.fn(), primaryActionButtonText: "Edit", secondaryActionButtonText: "Close", modalHeaderClassName: "custom-header-class", modalBodyClassName: "custom-body-class", modalFooterClassName: "custom-footer-class" }));
        const modal = screen.getByRole('dialog');
        const modalHeader = within(modal).getByRole('banner');
        expect(modalHeader).toHaveClass('custom-header-class');
        const modalBody = modal.querySelector('#code-modal-body');
        expect(modalBody).toHaveClass('custom-body-class');
        const modalfooter = within(modal).getByRole('contentinfo');
        expect(modalfooter).toHaveClass('custom-footer-class');
    }));
});
