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

34 lines
915 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 { 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', async () => {
2019-01-03 16:00:55 +03:00
const onClose = jest.fn();
render(<Notification onClose={onClose}>Message</Notification>);
2019-01-03 16:00:55 +03:00
await userEvent.click(screen.getByRole('button'));
expect(onClose).toHaveBeenCalled();
2019-01-03 16:00:55 +03:00
});
});