1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-04 23:14:56 +01:00
metamask-extension/ui/components/component-library/modal-overlay/modal-overlay.test.tsx

33 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-03-23 14:36:09 +01:00
import React from 'react';
import { render } from '@testing-library/react';
import { ModalOverlay } from './modal-overlay';
describe('ModalOverlay', () => {
it('should render ModalOverlay without error', () => {
const { getByTestId } = render(
<ModalOverlay data-testid="modal-overlay" />,
);
expect(getByTestId('modal-overlay')).toBeDefined();
expect(getByTestId('modal-overlay')).toHaveClass('mm-modal-overlay');
});
it('should match snapshot', () => {
const { container } = render(<ModalOverlay />);
expect(container).toMatchSnapshot();
});
it('should render with and additional className', () => {
const { getByTestId } = render(
<ModalOverlay data-testid="modal-overlay" className="test-class" />,
);
expect(getByTestId('modal-overlay')).toHaveClass('test-class');
});
it('should fire the onClick function when clicked', () => {
const onClick = jest.fn();
const { getByTestId } = render(
<ModalOverlay data-testid="modal-overlay" onClick={onClick} />,
);
getByTestId('modal-overlay').click();
expect(onClick).toHaveBeenCalled();
});
});