import * as __WEBPACK_EXTERNAL_MODULE__testing_library_react__ from "@testing-library/react";
import * as __WEBPACK_EXTERNAL_MODULE__Accordion_mjs__ from "./Accordion.mjs";
describe('Accordion', ()=>{
    test('should render accordion items with headings and descriptions', ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__Accordion_mjs__["default"], {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ]
        }));
        expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-button-0')).toBeVisible();
        expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-button-0')).toBeEnabled();
        expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-button-1')).toBeVisible();
        expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-button-1')).toBeEnabled();
        expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-button-0')).toHaveAttribute('aria-expanded', 'false');
        expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-button-1')).toHaveAttribute('aria-expanded', 'false');
        expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-item-description-0')).not.toBeVisible();
        expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-item-description-1')).not.toBeVisible();
    });
    test('should show the description for the expanded item', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__Accordion_mjs__["default"], {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ]
        }));
        __WEBPACK_EXTERNAL_MODULE__testing_library_react__.fireEvent.click(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-button-0'));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-button-0')).toHaveAttribute('aria-expanded', 'true');
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-item-description-0')).toBeVisible();
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-item-description-0')).toHaveTextContent('Description 1');
        });
    });
    test('should show the default item as expanded when provided in single mode', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__Accordion_mjs__["default"], {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ],
            defaultIndex: 0
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-item-description-0')).toBeVisible();
        });
    });
    test('should show the default items as expanded when provided in multi mode', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__Accordion_mjs__["default"], {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ],
            defaultIndex: [
                0,
                1
            ],
            allowMultiple: true
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-item-description-0')).toBeVisible();
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.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, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__Accordion_mjs__["default"], {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ],
            defaultIndex: 0,
            allowMultiple: false
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-item-description-0')).toBeVisible();
        });
        __WEBPACK_EXTERNAL_MODULE__testing_library_react__.fireEvent.click(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-button-1'));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-button-0')).toHaveAttribute('aria-expanded', 'false');
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-button-1')).toHaveAttribute('aria-expanded', 'true');
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-item-description-0')).not.toBeVisible();
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-item-description-1')).toBeVisible();
        });
    });
    test('should not hide the current item when multiple items can be shown', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__Accordion_mjs__["default"], {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ],
            defaultIndex: 0,
            allowMultiple: true
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-item-description-0')).toBeVisible();
        });
        __WEBPACK_EXTERNAL_MODULE__testing_library_react__.fireEvent.click(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-button-1'));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-item-description-0')).toBeVisible();
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-item-description-1')).toBeVisible();
        });
    });
    test('should show the completed steps when showCompleteStep is true', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__Accordion_mjs__["default"], {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ],
            showCompleteStep: true,
            defaultIndex: 0
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-complete-button-0')).toBeVisible();
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.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, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__Accordion_mjs__["default"], {
            items: [
                {
                    heading: 'Heading 1',
                    description: 'Description 1'
                },
                {
                    heading: 'Heading 2',
                    description: 'Description 2'
                }
            ],
            showCompleteStep: true,
            defaultIndex: [
                0
            ],
            allowMultiple: true
        }));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-complete-button-0')).toBeVisible();
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-complete-button-0')).toBeEnabled();
        });
        __WEBPACK_EXTERNAL_MODULE__testing_library_react__.fireEvent.click(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-complete-button-0'));
        await (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-complete-button-0')).toBeVisible();
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-complete-button-0')).toBeDisabled();
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-item-description-0')).toBeVisible();
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-item-description-1')).toBeVisible();
        });
    });
    test('should show the index completed based on completedIndex array', async ()=>{
        (0, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.render)(/*#__PURE__*/ React.createElement(__WEBPACK_EXTERNAL_MODULE__Accordion_mjs__["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, __WEBPACK_EXTERNAL_MODULE__testing_library_react__.waitFor)(()=>{
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-complete-button-0')).toBeVisible();
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getByTestId('accordion-complete-button-0')).toBeEnabled();
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getAllByTestId('accordion-icon').length).toEqual(2);
            expect(__WEBPACK_EXTERNAL_MODULE__testing_library_react__.screen.getAllByTestId('accordion-icon-complete').length).toEqual(1);
        });
    });
});
