redux-devtools/packages/redux-devtools-ui/test/Notification.test.tsx
renovate[bot] e9da5fc411
fix(deps): update react (major) (#1165)
* fix(deps): update react

* Fix

* Use createRoot

* Update tests

* Format

* Fix test

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Nathan Bierema <nbierema@gmail.com>
2022-06-06 16:22:05 +00:00

34 lines
914 B
TypeScript

import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { Notification } from '../src';
describe('Notification', function () {
it('renders correctly', () => {
const { container } = render(<Notification>Message</Notification>);
expect(container.firstChild).toMatchSnapshot();
});
it('renders with props', () => {
const { container } = render(
<Notification
type="error"
onClose={() => {
// noop
}}
>
Message
</Notification>
);
expect(container.firstChild).toMatchSnapshot();
});
it('should handle the click event', async () => {
const onClose = jest.fn();
render(<Notification onClose={onClose}>Message</Notification>);
await userEvent.click(screen.getByRole('button'));
expect(onClose).toHaveBeenCalled();
});
});