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

20 lines
587 B
TypeScript
Raw 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', () => {
const onClick = jest.fn();
render(<Button onClick={onClick}>ClickMe</Button>);
2019-01-03 16:00:55 +03:00
userEvent.click(screen.getByRole('button'));
expect(onClick).toHaveBeenCalled();
2019-01-03 16:00:55 +03:00
});
});