import { mockMatchMedia, render, screen } from '../../test-utils';
import { ListItem, type ListItemProps } from '../ListItem';
mockMatchMedia();
const baseProps = {
title: 'Test Title',
};
const avatarProps = {
imgSrc: 'avatar.jpg',
profileName: 'User Avatar',
};
const renderWithMedia = (media: ListItemProps['media']) =>
render();
describe('ListItem.AvatarView', () => {
it('applies custom className alongside default class', () => {
const { container } = renderWithMedia(
,
);
expect(container.querySelector('.custom-class')).toBeInTheDocument();
});
it('renders avatar with correct image src', () => {
renderWithMedia(
,
);
expect(screen.getByRole('presentation')).toHaveAttribute('src', avatarProps.imgSrc);
});
it('renders without image when no imgSrc provided', () => {
renderWithMedia();
expect(screen.queryByRole('img')).not.toBeInTheDocument();
});
it('supports accessibility props', () => {
renderWithMedia(
,
);
expect(screen.getByLabelText('Profile picture')).toBeInTheDocument();
});
it('passes through role attribute', () => {
renderWithMedia(
,
);
expect(screen.getByRole('button', { name: 'Profile button' })).toBeInTheDocument();
});
it('renders initials when no image provided', () => {
const johnDoeProfile = 'John Doe';
renderWithMedia();
expect(screen.getByText('JD')).toBeInTheDocument();
});
});