import React from 'react'; import { fireEvent, render, screen } from '../../../../jest/test-helpers'; import Button from '../button'; describe('); expect(screen.getByRole('button')).toHaveTextContent('children'); }); it('renders the props.text instead of children', () => { const text = 'foo'; const children =

children

; render(); expect(screen.getByRole('button')).toHaveTextContent('foo'); expect(screen.getByRole('button')).not.toHaveTextContent('children'); }); it('handles click events using the given handler', () => { const handler = jest.fn(); render(); expect(screen.getByRole('link')).toBeInTheDocument(); }); it('does not render a link', () => { render(); expect(screen.queryAllByRole('link')).toHaveLength(0); }); }); describe('icon prop', () => { it('renders an icon', () => { render(); expect(screen.getByTestId('icon')).toBeInTheDocument(); }); it('does not render an icon', () => { render(); expect(screen.queryAllByTestId('icon')).toHaveLength(0); }); }); });