"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());
    });
};
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 PreviewAttachment_1 = require("./PreviewAttachment");
describe('PreviewAttachment', () => {
    it('should render PreviewAttachment', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(PreviewAttachment_1.PreviewAttachment, { code: "Hello world", fileName: "greetings.txt", isModalOpen: true, onEdit: jest.fn(), handleModalToggle: jest.fn() }));
        expect(react_1.screen.getByText('Preview attachment')).toBeTruthy();
        expect(react_1.screen.getByText('greetings')).toBeTruthy();
        expect(react_1.screen.getAllByText('TEXT')).toBeTruthy();
    });
    it('should call onEdit handler when edit button is pressed', () => {
        const onEdit = jest.fn();
        (0, react_1.render)((0, jsx_runtime_1.jsx)(PreviewAttachment_1.PreviewAttachment, { code: "Hello world", fileName: "greetings.txt", isModalOpen: true, onEdit: onEdit, handleModalToggle: jest.fn() }));
        react_1.fireEvent.click(react_1.screen.getByText('Edit'));
        expect(onEdit).toHaveBeenCalled();
    });
    it('should call onDismiss handler when dismiss button is pressed', () => {
        const onDismiss = jest.fn();
        (0, react_1.render)((0, jsx_runtime_1.jsx)(PreviewAttachment_1.PreviewAttachment, { code: "Hello world", fileName: "greetings.txt", isModalOpen: true, onEdit: jest.fn(), handleModalToggle: onDismiss }));
        react_1.fireEvent.click(react_1.screen.getByText('Dismiss'));
        expect(onDismiss).toHaveBeenCalled();
    });
    it('should render custom button text for footer actions buttons', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(PreviewAttachment_1.PreviewAttachment, { code: "Hello world", fileName: "greetings.txt", isModalOpen: true, onEdit: jest.fn(), handleModalToggle: jest.fn(), primaryActionButtonText: "Edit", secondaryActionButtonText: "Close" }));
        react_1.screen.getByText('Edit');
        react_1.screen.getByText('Close');
    });
    it('should render PreviewAttachment with custom classNames', () => __awaiter(void 0, void 0, void 0, function* () {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(PreviewAttachment_1.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 = react_1.screen.getByRole('dialog');
        const modalHeader = (0, react_1.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 = (0, react_1.within)(modal).getByRole('contentinfo');
        expect(modalfooter).toHaveClass('custom-footer-class');
    }));
});
