mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-01 21:57:06 +01:00
68f928c8a2
* Adding ModalContent component * Using different component api for ref * use imperative handle * Updating size * Updating stories and docs as well as component api * Fixing import
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
/* eslint-disable jest/require-top-level-describe */
|
|
import { render } from '@testing-library/react';
|
|
import React from 'react';
|
|
|
|
import { ModalContent } from './modal-content';
|
|
import { ModalContentSize } from './modal-content.types';
|
|
|
|
describe('ModalContent', () => {
|
|
it('should render with text inside the ModalContent', () => {
|
|
const { getByText } = render(<ModalContent>test</ModalContent>);
|
|
expect(getByText('test')).toBeDefined();
|
|
expect(getByText('test')).toHaveClass('mm-modal-content');
|
|
});
|
|
it('should match snapshot', () => {
|
|
const { container } = render(<ModalContent>test</ModalContent>);
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
it('should render with and additional className', () => {
|
|
const { getByText } = render(
|
|
<ModalContent className="test-class">test</ModalContent>,
|
|
);
|
|
expect(getByText('test')).toHaveClass('test-class');
|
|
});
|
|
it('should render with size sm', () => {
|
|
const { getByText } = render(
|
|
<>
|
|
<ModalContent>default</ModalContent>
|
|
<ModalContent size={ModalContentSize.Sm}>sm</ModalContent>
|
|
</>,
|
|
);
|
|
expect(getByText('sm')).toHaveClass('mm-modal-content--size-sm');
|
|
expect(getByText('default')).toHaveClass('mm-modal-content--size-sm');
|
|
});
|
|
it('should render with a ref', () => {
|
|
const ref = React.createRef<HTMLDivElement>();
|
|
render(<ModalContent modalContentRef={ref}>test</ModalContent>);
|
|
expect(ref.current).toBeDefined();
|
|
});
|
|
});
|