"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 external_Accordion_js_namespaceObject = require("./Accordion.js");
var external_Accordion_js_default = /*#__PURE__*/ __webpack_require__.n(external_Accordion_js_namespaceObject);
describe('Accordion', ()=>{
    test('should render accordion items with headings and descriptions', ()=>{
        (0, react_namespaceObject.render)(/*#__PURE__*/ React.createElement(external_Accordion_js_default(), {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ]
        }));
        expect(react_namespaceObject.screen.getByTestId('accordion-button-0')).toBeVisible();
        expect(react_namespaceObject.screen.getByTestId('accordion-button-0')).toBeEnabled();
        expect(react_namespaceObject.screen.getByTestId('accordion-button-1')).toBeVisible();
        expect(react_namespaceObject.screen.getByTestId('accordion-button-1')).toBeEnabled();
        expect(react_namespaceObject.screen.getByTestId('accordion-button-0')).toHaveAttribute('aria-expanded', 'false');
        expect(react_namespaceObject.screen.getByTestId('accordion-button-1')).toHaveAttribute('aria-expanded', 'false');
        expect(react_namespaceObject.screen.getByTestId('accordion-item-description-0')).not.toBeVisible();
        expect(react_namespaceObject.screen.getByTestId('accordion-item-description-1')).not.toBeVisible();
    });
    test('should show the description for the expanded item', async ()=>{
        (0, react_namespaceObject.render)(/*#__PURE__*/ React.createElement(external_Accordion_js_default(), {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ]
        }));
        react_namespaceObject.fireEvent.click(react_namespaceObject.screen.getByTestId('accordion-button-0'));
        await (0, react_namespaceObject.waitFor)(()=>{
            expect(react_namespaceObject.screen.getByTestId('accordion-button-0')).toHaveAttribute('aria-expanded', 'true');
            expect(react_namespaceObject.screen.getByTestId('accordion-item-description-0')).toBeVisible();
            expect(react_namespaceObject.screen.getByTestId('accordion-item-description-0')).toHaveTextContent('Description 1');
        });
    });
    test('should show the default item as expanded when provided in single mode', async ()=>{
        (0, react_namespaceObject.render)(/*#__PURE__*/ React.createElement(external_Accordion_js_default(), {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ],
            defaultIndex: 0
        }));
        await (0, react_namespaceObject.waitFor)(()=>{
            expect(react_namespaceObject.screen.getByTestId('accordion-item-description-0')).toBeVisible();
        });
    });
    test('should show the default items as expanded when provided in multi mode', async ()=>{
        (0, react_namespaceObject.render)(/*#__PURE__*/ React.createElement(external_Accordion_js_default(), {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ],
            defaultIndex: [
                0,
                1
            ],
            allowMultiple: true
        }));
        await (0, react_namespaceObject.waitFor)(()=>{
            expect(react_namespaceObject.screen.getByTestId('accordion-item-description-0')).toBeVisible();
            expect(react_namespaceObject.screen.getByTestId('accordion-item-description-1')).toBeVisible();
        });
    });
    test('should hide the current item when only 1 item can be shown at once and a new item is clicked', async ()=>{
        (0, react_namespaceObject.render)(/*#__PURE__*/ React.createElement(external_Accordion_js_default(), {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ],
            defaultIndex: 0,
            allowMultiple: false
        }));
        await (0, react_namespaceObject.waitFor)(()=>{
            expect(react_namespaceObject.screen.getByTestId('accordion-item-description-0')).toBeVisible();
        });
        react_namespaceObject.fireEvent.click(react_namespaceObject.screen.getByTestId('accordion-button-1'));
        await (0, react_namespaceObject.waitFor)(()=>{
            expect(react_namespaceObject.screen.getByTestId('accordion-button-0')).toHaveAttribute('aria-expanded', 'false');
            expect(react_namespaceObject.screen.getByTestId('accordion-button-1')).toHaveAttribute('aria-expanded', 'true');
            expect(react_namespaceObject.screen.getByTestId('accordion-item-description-0')).not.toBeVisible();
            expect(react_namespaceObject.screen.getByTestId('accordion-item-description-1')).toBeVisible();
        });
    });
    test('should not hide the current item when multiple items can be shown', async ()=>{
        (0, react_namespaceObject.render)(/*#__PURE__*/ React.createElement(external_Accordion_js_default(), {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ],
            defaultIndex: 0,
            allowMultiple: true
        }));
        await (0, react_namespaceObject.waitFor)(()=>{
            expect(react_namespaceObject.screen.getByTestId('accordion-item-description-0')).toBeVisible();
        });
        react_namespaceObject.fireEvent.click(react_namespaceObject.screen.getByTestId('accordion-button-1'));
        await (0, react_namespaceObject.waitFor)(()=>{
            expect(react_namespaceObject.screen.getByTestId('accordion-item-description-0')).toBeVisible();
            expect(react_namespaceObject.screen.getByTestId('accordion-item-description-1')).toBeVisible();
        });
    });
    test('should show the completed steps when showCompleteStep is true', async ()=>{
        (0, react_namespaceObject.render)(/*#__PURE__*/ React.createElement(external_Accordion_js_default(), {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ],
            showCompleteStep: true,
            defaultIndex: 0
        }));
        await (0, react_namespaceObject.waitFor)(()=>{
            expect(react_namespaceObject.screen.getByTestId('accordion-complete-button-0')).toBeVisible();
            expect(react_namespaceObject.screen.getByTestId('accordion-complete-button-0')).toBeEnabled();
        });
    });
    test('should move to another step and disable the previous complete button when in multi mode', async ()=>{
        (0, react_namespaceObject.render)(/*#__PURE__*/ React.createElement(external_Accordion_js_default(), {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ],
            showCompleteStep: true,
            defaultIndex: [
                0
            ],
            allowMultiple: true
        }));
        await (0, react_namespaceObject.waitFor)(()=>{
            expect(react_namespaceObject.screen.getByTestId('accordion-complete-button-0')).toBeVisible();
            expect(react_namespaceObject.screen.getByTestId('accordion-complete-button-0')).toBeEnabled();
        });
        react_namespaceObject.fireEvent.click(react_namespaceObject.screen.getByTestId('accordion-complete-button-0'));
        await (0, react_namespaceObject.waitFor)(()=>{
            expect(react_namespaceObject.screen.getByTestId('accordion-complete-button-0')).toBeVisible();
            expect(react_namespaceObject.screen.getByTestId('accordion-complete-button-0')).toBeDisabled();
            expect(react_namespaceObject.screen.getByTestId('accordion-item-description-0')).toBeVisible();
            expect(react_namespaceObject.screen.getByTestId('accordion-item-description-1')).toBeVisible();
        });
    });
    test('should show the index completed based on completedIndex array', async ()=>{
        (0, react_namespaceObject.render)(/*#__PURE__*/ React.createElement(external_Accordion_js_default(), {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                },
                {
                    heading: 'Heading 3',
                    description: 'Description 3'
                },
                {
                    heading: 'Heading 3',
                    description: 'Description 4'
                }
            ],
            showCompleteStep: true,
            defaultIndex: 0,
            completedSteps: [
                0
            ]
        }));
        await (0, react_namespaceObject.waitFor)(()=>{
            expect(react_namespaceObject.screen.getByTestId('accordion-complete-button-0')).toBeVisible();
            expect(react_namespaceObject.screen.getByTestId('accordion-complete-button-0')).toBeEnabled();
            expect(react_namespaceObject.screen.getAllByTestId('accordion-icon').length).toEqual(2);
            expect(react_namespaceObject.screen.getAllByTestId('accordion-icon-complete').length).toEqual(1);
        });
    });
});
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
});
