import React from 'react'; import { render, screen } from '@testing-library/react'; import { DropdownItem } from './'; describe('DropdownItem component', () => { describe('given default props', () => { it('displays the label as child', () => { render(); expect(screen.getByText('My dropdown item')).toBeVisible(); }); }); describe('given a `prefix` props', () => { it('renders the prefix element', () => { render( Prefix} />, ); expect(screen.getByText('Prefix')).toBeVisible(); }); }); describe('given a `suffix` props', () => { it('renders the suffix element', () => { render( Suffix} />, ); expect(screen.getByText('Suffix')).toBeVisible(); }); }); describe('given a `helpText` props', () => { it('renders this text', () => { const helpText = 'Put something helpful here'; render(); expect(screen.getByText(helpText)).toBeVisible(); }); }); describe('given a complex `helpText` props', () => { beforeEach(() => { vi.spyOn(console, 'error').mockClear(); }); it('renders the given react node', () => { render(
  • item 1
  • item 2
  • item 3
  • } />, ); expect(console.error).not.toHaveBeenCalled(); expect(screen.getByText('item 1')).toBeVisible(); expect(screen.getByText('item 2')).toBeVisible(); expect(screen.getByText('item 3')).toBeVisible(); }); }); });