"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const react_2 = require("@testing-library/react");
const AttachmentEdit_1 = __importDefault(require("./AttachmentEdit"));
describe('AttachmentEdit', () => {
    it('should open AttachmentEdit modal', () => {
        const props = {
            code: 'code',
            fileName: 'fileName',
            onCancel: jest.fn(),
            onSave: jest.fn(),
            isModalOpen: true,
            handleModalToggle: jest.fn()
        };
        (0, react_2.render)(react_1.default.createElement(AttachmentEdit_1.default, Object.assign({}, props)));
        expect(react_2.screen.getByText('Edit attachment')).toBeTruthy();
    });
    it('should call onSave handler when the save button is clicked', () => {
        const onSaveHandler = jest.fn();
        const props = {
            code: 'code',
            fileName: 'fileName',
            onCancel: jest.fn(),
            onSave: onSaveHandler,
            isModalOpen: true,
            handleModalToggle: jest.fn()
        };
        (0, react_2.render)(react_1.default.createElement(AttachmentEdit_1.default, Object.assign({}, props)));
        // Click on save button
        react_2.fireEvent.click(react_2.screen.getByText('Save'));
        expect(onSaveHandler).toHaveBeenCalledWith(expect.any(Object), 'code');
    });
    it('should call cancel handler when the cancel button is clicked', () => {
        const onCancelHandler = jest.fn();
        const props = {
            code: 'code',
            fileName: 'fileName',
            onCancel: onCancelHandler,
            onSave: jest.fn(),
            isModalOpen: true,
            handleModalToggle: jest.fn()
        };
        (0, react_2.render)(react_1.default.createElement(AttachmentEdit_1.default, Object.assign({}, props)));
        // Click on cancel button
        react_2.fireEvent.click(react_2.screen.getByText('Cancel'));
        expect(onCancelHandler).toHaveBeenCalled();
    });
});
