import { render, screen } from '../../test-utils';
import { ListItem, type ListItemProps } from '../ListItem';
describe('ListItem.AdditionalInfo', () => {
const renderWithInfo = (info: ListItemProps['additionalInfo']) =>
render();
it('renders children content', () => {
renderWithInfo(
Additional information content,
);
expect(screen.getByText('Additional information content')).toBeInTheDocument();
});
it('renders action button when onClick provided', () => {
const handleActionClick = jest.fn();
renderWithInfo(
Additional info
,
);
expect(screen.getByRole('button', { name: 'Learn more' })).toBeInTheDocument();
});
it('renders action link with href when provided', () => {
renderWithInfo(
Additional info
,
);
const actionLink = screen.getByRole('link', { name: 'Learn more' });
expect(actionLink).toBeInTheDocument();
expect(actionLink).toHaveAttribute('href', '/learn');
});
it('renders action link with target when provided', () => {
renderWithInfo(
Additional info
,
);
const actionLink = screen.getByRole('link', { name: 'Learn more (opens in new tab)' });
expect(actionLink).toBeInTheDocument();
expect(actionLink).toHaveAttribute('target', '_blank');
});
it('does not render action when not provided', () => {
renderWithInfo(Additional info only);
expect(screen.queryByRole('link')).not.toBeInTheDocument();
expect(screen.queryByRole('button')).not.toBeInTheDocument();
});
});