File size: 597 Bytes
9705b6c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import { render, fireEvent } from '@testing-library/react';
import Stop from '../Stop';
describe('Stop', () => {
it('should render the Stop button', () => {
const { getByText } = render(
<Stop
onClick={() => {
('');
}}
/>,
);
expect(getByText('Stop')).toBeInTheDocument();
});
it('should call onClick when the button is clicked', () => {
const handleClick = jest.fn();
const { getByText } = render(<Stop onClick={handleClick} />);
fireEvent.click(getByText('Stop'));
expect(handleClick).toHaveBeenCalledTimes(1);
});
});
|