import { describe, it, expect, vi, beforeEach } from 'vitest'; import { mount } from '@vue/test-utils'; import { nextTick } from 'vue'; import VModal from '../src/components/modal/VModal.vue'; import type IVButton from '../src/components/button/IVButton.type'; describe('VModal.vue', () => { let actions: IVButton[]; let visible: boolean; beforeEach(() => { visible = true; actions = [ { label: 'Bouton primaire', onClick: vi.fn(), title: 'primaire', }, { label: 'Bouton secondaire', secondary: true, onClick: vi.fn(), title: 'secondaire', }, { label: 'Bouton tertiaire', tertiary: true, onClick: vi.fn(), title: 'tertiaire', }, ]; }); it('emits update:visible when internal visibility changes', async () => { const wrapper = mount(VModal, { props: { visible: true, actions, }, }); // Simulation d’un changement interne await wrapper.vm.$emit('update:visible', false); await nextTick(); const emitted = wrapper.emitted('update:visible'); expect(emitted).toBeTruthy(); expect(emitted?.[0]).toEqual([false]); }); it('emits lifecycle events (show/hide)', async () => { const wrapper = mount(VModal, { props: { visible, actions, }, }); wrapper.vm.$emit('show'); wrapper.vm.$emit('hide'); await nextTick(); expect(wrapper.emitted('show')).toBeTruthy(); expect(wrapper.emitted('hide')).toBeTruthy(); }); });