import React from 'react'; import { render, screen } from '@testing-library/react'; import { ListView, ListItem } from './'; describe('ListView component', () => { it('should display all the items', () => { render( Supplier1 Supplier2 Supplier3 , ); expect(screen.getByRole('list', { name: 'Suppliers' })).toBeVisible(); expect(screen.getAllByRole('listitem')).toHaveLength(3); expect(screen.getByText('Supplier1')).toBeVisible(); expect(screen.getByText('Supplier2')).toBeVisible(); expect(screen.getByText('Supplier3')).toBeVisible(); }); it('should assign className', () => { render( Supplier1 , ); expect(screen.getByRole('list', { name: 'Suppliers' })).toHaveClass( 'supplierClassName', ); expect(screen.getByRole('listitem')).toHaveClass('supplier1Class'); }); });