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

34 lines
902 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 { Notification } from '../src';
describe('Notification', function () {
2019-01-03 16:00:55 +03:00
it('renders correctly', () => {
const { container } = render(<Notification>Message</Notification>);
expect(container.firstChild).toMatchSnapshot();
2019-01-03 16:00:55 +03:00
});
it('renders with props', () => {
const { container } = render(
<Notification
type="error"
onClose={() => {
// noop
}}
>
2019-01-10 21:51:14 +03:00
Message
</Notification>
2019-01-03 16:00:55 +03:00
);
expect(container.firstChild).toMatchSnapshot();
2019-01-03 16:00:55 +03:00
});
it('should handle the click event', () => {
const onClose = jest.fn();
render(<Notification onClose={onClose}>Message</Notification>);
2019-01-03 16:00:55 +03:00
userEvent.click(screen.getByRole('button'));
expect(onClose).toHaveBeenCalled();
2019-01-03 16:00:55 +03:00
});
});