import { render, screen } from '../../test-utils'; import userEvent from '@testing-library/user-event'; import { ListItem, type ListItemProps } from '../ListItem'; describe('ListItem.Radio', () => { const renderWith = (overrides: Partial = {}) => render(); it('renders radio button', () => { renderWith({ control: {}} />, }); expect(screen.getByRole('radio')).toBeInTheDocument(); }); describe('checked state', () => { it('reflects checked state', () => { renderWith({ control: , }); expect(screen.getByRole('radio')).toBeChecked(); }); it('reflects unchecked state', () => { renderWith({ control: , }); expect(screen.getByRole('radio')).not.toBeChecked(); }); }); it('handles onChange events', async () => { const handleChange = jest.fn(); renderWith({ control: , }); await userEvent.click(screen.getByRole('radio')); expect(handleChange).toHaveBeenCalledTimes(1); }); it('is disabled when ListItem is disabled', async () => { const handleChange = jest.fn(); renderWith({ disabled: true, control: , }); const radio = screen.getByRole('radio'); expect(radio).toBeDisabled(); await userEvent.click(radio); expect(handleChange).not.toHaveBeenCalled(); }); it('supports name and value attributes', () => { renderWith({ control: }); const radio = screen.getByRole('radio'); expect(radio).toHaveAttribute('name', 'test-radio'); // eslint-disable-next-line jest-dom/prefer-to-have-value expect(radio).toHaveAttribute('value', 'option1'); }); });