import { render, fireEvent } from '@testing-library/svelte';
import { describe, it, expect } from 'vitest';
import AccordionList from './AccordionList.svelte';
describe('AccordionList', () => {
    it('renders with default props', () => {
        const { container } = render(AccordionList);
        const accordion = container.querySelector('.mc-accordion');
        expect(accordion).toBeTruthy();
        expect(accordion?.classList.contains('mc-accordion--ghost')).toBe(false);
    });
    it('applies ghost appearance', () => {
        const { container } = render(AccordionList, { appearance: 'ghost' });
        const accordion = container.querySelector('.mc-accordion');
        expect(accordion?.classList.contains('mc-accordion--ghost')).toBe(true);
    });
    it('handles multiple behavior', async () => {
        const { container, component } = render(AccordionList, { behavior: 'multiple' });
        const element = container.querySelector('.mc-accordion');
        await fireEvent(element, new CustomEvent('update:open', { detail: { id: 'item1' } }));
        await fireEvent(element, new CustomEvent('update:open', { detail: { id: 'item2' } }));
        expect(component.value).toContain('item1');
        expect(component.value).toContain('item2');
    });
    it('handles single behavior', async () => {
        const { container, component } = render(AccordionList, { behavior: 'single' });
        const element = container.querySelector('.mc-accordion');
        await fireEvent(element, new CustomEvent('update:open', { detail: { id: 'item1' } }));
        expect(component.value).toEqual(['item1']);
        await fireEvent(element, new CustomEvent('update:open', { detail: { id: 'item2' } }));
        expect(component.value).toEqual(['item2']);
    });
    it('toggles items in multiple mode', async () => {
        const { container, component } = render(AccordionList, { behavior: 'multiple' });
        const element = container.querySelector('.mc-accordion');
        await fireEvent(element, new CustomEvent('update:open', { detail: { id: 'item1' } }));
        expect(component.value).toContain('item1');
        await fireEvent(element, new CustomEvent('update:open', { detail: { id: 'item1' } }));
        expect(component.value).not.toContain('item1');
    });
});
