import { fireEvent, render, screen } from '@testing-library/react' import { describe, expect, it, vi } from 'vitest' import DeleteModal from './DeleteModal' describe('DeleteModal', () => { it('renders nothing when closed', () => { render() expect(screen.queryByRole('dialog')).not.toBeInTheDocument() }) it('renders the dialog with the note title when open', () => { render() expect(screen.getByRole('dialog', { name: 'Supprimer la note ?' })).toBeInTheDocument() expect(screen.getByText(/Courses/)).toBeInTheDocument() }) it('shows a placeholder when the note has no title', () => { render() expect(screen.getByText(/Sans titre/)).toBeInTheDocument() }) it('calls onConfirm when the confirm button is clicked', () => { const onConfirm = vi.fn() render() fireEvent.click(screen.getByRole('button', { name: 'Supprimer' })) expect(onConfirm).toHaveBeenCalled() }) it('calls onCancel when the cancel button is clicked', () => { const onCancel = vi.fn() render() fireEvent.click(screen.getByRole('button', { name: 'Annuler' })) expect(onCancel).toHaveBeenCalled() }) })