"use strict";
// The require scope
var __webpack_require__ = {};
/************************************************************************/ // webpack/runtime/compat_get_default_export
(()=>{
    // getDefaultExport function for compatibility with non-ESM modules
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
// webpack/runtime/define_property_getters
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
// webpack/runtime/has_own_property
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
/************************************************************************/ var __webpack_exports__ = {};
const react_namespaceObject = require("@testing-library/react");
const user_event_namespaceObject = require("@testing-library/user-event");
var user_event_default = /*#__PURE__*/ __webpack_require__.n(user_event_namespaceObject);
const external_ConfirmModal_js_namespaceObject = require("./ConfirmModal.js");
var external_ConfirmModal_js_default = /*#__PURE__*/ __webpack_require__.n(external_ConfirmModal_js_namespaceObject);
describe('ConfirmModal', ()=>{
    test('should render modal trigger button', async ()=>{
        (0, react_namespaceObject.render)(/*#__PURE__*/ React.createElement(external_ConfirmModal_js_default(), {
            trigger: "Confirm button",
            heading: "Confirm",
            onConfirm: ()=>{
                console.log('yes, you confirmed!');
            },
            onClose: ()=>{
                console.log('modal cancelled...');
            }
        }, "Are you sure?"));
        const triggerButton = react_namespaceObject.screen.queryByRole('button');
        expect(triggerButton).toBeVisible();
        expect(triggerButton?.textContent).toBe('Confirm button');
    });
    test('should display modal with title after clicking trigger button', async ()=>{
        user_event_default().setup();
        (0, react_namespaceObject.render)(/*#__PURE__*/ React.createElement(external_ConfirmModal_js_default(), {
            trigger: "Confirm",
            heading: "Confirm Heading",
            onConfirm: ()=>{
                console.log('yes, you confirmed!');
            },
            onClose: ()=>{
                console.log('modal cancelled...');
            }
        }, "Are you sure?"));
        const triggerButton = react_namespaceObject.screen.getByRole('button', {
            name: 'Confirm'
        });
        await user_event_default().click(triggerButton);
        const modalHeading = react_namespaceObject.screen.getByText(/Confirm heading/i);
        const modalContent = react_namespaceObject.screen.queryByText(/are you sure\?/i);
        expect(modalHeading).toBeVisible();
        expect(modalContent).toBeVisible();
    });
    test('should display modal with custom action button labels after clicking trigger button', async ()=>{
        const mockOnConfirm = jest.fn();
        const mockOnClose = jest.fn();
        user_event_default().setup();
        (0, react_namespaceObject.render)(/*#__PURE__*/ React.createElement(external_ConfirmModal_js_default(), {
            trigger: "Confirm",
            heading: "Confirm Heading",
            primaryActionLabel: "Do it",
            secondaryActionLabel: "Forget it",
            onConfirm: mockOnConfirm,
            onClose: mockOnClose
        }, "Are you sure?"));
        const triggerButton = react_namespaceObject.screen.getByRole('button', {
            name: 'Confirm'
        });
        await user_event_default().click(triggerButton);
        const modalCancelButton = react_namespaceObject.screen.getByRole('button', {
            name: 'Do it'
        });
        const modalConfirmButton = react_namespaceObject.screen.getByRole('button', {
            name: 'Forget it'
        });
        expect(modalCancelButton).toBeVisible();
        expect(modalConfirmButton).toBeVisible();
    });
    test('should trigger onConfirm function when clicking the confirm button', async ()=>{
        const mockOnConfirm = jest.fn();
        const mockOnClose = jest.fn();
        (0, react_namespaceObject.render)(/*#__PURE__*/ React.createElement(external_ConfirmModal_js_default(), {
            trigger: "Confirm trigger",
            heading: "Confirm Heading",
            onConfirm: mockOnConfirm,
            onClose: mockOnClose
        }, "Are you sure?"));
        const triggerButton = react_namespaceObject.screen.getByRole('button', {
            name: 'Confirm trigger'
        });
        await user_event_default().click(triggerButton);
        const modalConfirmButton = react_namespaceObject.screen.getByRole('button', {
            name: 'Confirm'
        });
        react_namespaceObject.fireEvent.click(modalConfirmButton);
        await (0, react_namespaceObject.waitFor)(()=>{
            expect(mockOnConfirm).toHaveBeenCalled();
            expect(mockOnClose).not.toHaveBeenCalled();
        });
    });
    test('should trigger onClose function when clicking cancel button', async ()=>{
        const mockOnConfirm = jest.fn();
        const mockOnClose = jest.fn();
        (0, react_namespaceObject.render)(/*#__PURE__*/ React.createElement(external_ConfirmModal_js_default(), {
            trigger: "Confirm",
            heading: "Confirm Heading",
            onConfirm: mockOnConfirm,
            onClose: mockOnClose
        }, "Are you sure?"));
        const triggerButton = react_namespaceObject.screen.getByRole('button', {
            name: 'Confirm'
        });
        await user_event_default().click(triggerButton);
        const modalCancelButton = react_namespaceObject.screen.getByRole('button', {
            name: 'Cancel'
        });
        react_namespaceObject.fireEvent.click(modalCancelButton);
        await (0, react_namespaceObject.waitFor)(()=>{
            expect(mockOnClose).toHaveBeenCalled();
            expect(mockOnConfirm).not.toHaveBeenCalled();
        });
    });
});
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
