import { render, screen } from '@testing-library/react'; import { ModalDeck } from './ModalDeck'; import { Button } from '@patternfly/react-core'; describe('ModalDeck component', () => { test('should render when open', () => { const { container } = render(
Modal content
); expect(screen.getByText('Modal content')).toBeInTheDocument(); expect(container).toMatchSnapshot(); }); test('should not render when closed', () => { render(
Modal content
); expect(screen.queryByText('Modal content')).not.toBeInTheDocument(); }); test('should render children', () => { render(
Test content
); expect(screen.getByTestId('test-child')).toBeInTheDocument(); expect(screen.getByText('Test content')).toBeInTheDocument(); }); test('should apply small variant by default', () => { render(
Content
); const modal = screen.getByRole('dialog'); expect(modal).toBeInTheDocument(); // Small variant is the default, just verify modal renders }); test('should pass through modalProps', () => { render(
Content
); const modal = screen.getByRole('dialog'); expect(modal).toHaveAttribute('aria-label', 'Custom modal label'); expect(modal).toHaveAttribute('aria-describedby', 'custom-description'); }); test('should override variant through modalProps', () => { render(
Content
); const modal = screen.getByRole('dialog'); expect(modal).toBeInTheDocument(); // Variant override is passed through modalProps, just verify modal renders }); });