redux-devtools/packages/redux-devtools-ui/test/Button.test.tsx

20 lines
599 B
TypeScript
Raw Permalink Normal View History

2019-01-03 16:00:55 +03:00
import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
2019-01-03 16:00:55 +03:00
import { Button } from '../src';
describe('Button', function () {
2019-01-03 16:00:55 +03:00
it('renders correctly', () => {
const { container } = render(<Button>Text</Button>);
expect(container.firstChild).toMatchSnapshot();
2019-01-03 16:00:55 +03:00
});
it('should handle the click event', async () => {
2019-01-03 16:00:55 +03:00
const onClick = jest.fn();
render(<Button onClick={onClick}>ClickMe</Button>);
2019-01-03 16:00:55 +03:00
await userEvent.click(screen.getByRole('button'));
expect(onClick).toHaveBeenCalled();
2019-01-03 16:00:55 +03:00
});
});