import { render, screen, userEvent } from '../../test-utils'; import Chip from './Chip'; describe('Chip', () => { it('calls onClick when clicked', async () => { const onClick = jest.fn(); render(); await userEvent.click(screen.getByRole('button', { name: 'Accounting' })); expect(onClick).toHaveBeenCalled(); }); describe('when disabled', () => { it('does not call onClick when clicked', async () => { const onClick = jest.fn(); render(); await userEvent.click(screen.getByRole('button', { name: 'Accounting' })); expect(onClick).not.toHaveBeenCalled(); }); it('marks an actionable chip as disabled and takes it out of the tab order', () => { render( {}} />); const chip = screen.getByRole('button', { name: 'Accounting' }); expect(chip).toHaveAttribute('aria-disabled', 'true'); expect(chip).toHaveAttribute('tabindex', '-1'); expect(chip).toHaveClass('disabled'); }); }); });