import * as React from 'react'; import { renderHook } from '@testing-library/react-hooks'; import { Dialog } from '../index'; import render from '../../utils/_tests/render'; describe('props', () => { it('should render correctly', () => { const { container } = render(Hello world); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with CSS props', () => { const { container } = render(Hello world); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with a title', () => { const { container } = render(Hello world); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with a close button', () => { const { container } = render( Hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with action buttons', () => { const { container } = render( Hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with a footer', () => { const { container } = render( Hello world ); expect(container.firstChild).toMatchSnapshot(); }); describe('type', () => { ['info', 'success', 'danger', 'warning'].forEach((type) => { it(`should render correctly with type ${type}`, () => { const { container } = render( Hello world ); expect(container.firstChild).toMatchSnapshot(); }); }); }); it('should render correctly for standalone', () => { const { container } = render( Example Dialog Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse diam ipsum, cursus id placerat congue, ultrices eget lectus. Duis posuere, lacus sed tristique commodo, sapien turpis mollis nunc, vestibulum consectetur lectus augue sit amet justo. This is a footer ); expect(container.firstChild).toMatchSnapshot(); }); }); describe('composition', () => { describe('as', () => { it('should render correctly', () => { const { container } = render(Hello world); expect(container.firstChild).toMatchSnapshot(); }); }); describe('hook', () => { it('should return with Dialog props', () => { const { result } = renderHook(() => Dialog.useProps()); expect(result.current).toMatchSnapshot(); }); }); describe('render props', () => { it('should render correctly', () => { const { container } = render({(DialogProps) =>
Hello world
}
); expect(container.firstChild).toMatchSnapshot(); }); }); }); describe('overrides', () => { it('Dialog.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Dialog.Content.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Dialog.Header.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Dialog.Title.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Dialog.Footer.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Dialog.IconWrapper.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Dialog.Close.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); }); describe('theming', () => { it('Dialog.base should render correctly', () => { const { container } = render(hello world, { theme: { Dialog: { styles: { base: { backgroundColor: 'red' } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Dialog.Content.base should render correctly', () => { const { container } = render(hello world, { theme: { Dialog: { Content: { styles: { base: { backgroundColor: 'red' } } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Dialog.Header.base should render correctly', () => { const { container } = render(hello world, { theme: { Dialog: { Header: { styles: { base: { backgroundColor: 'red' } } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Dialog.Title.base should render correctly', () => { const { container } = render(hello world, { theme: { Dialog: { Title: { styles: { base: { backgroundColor: 'red' } } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Dialog.Footer.base should render correctly', () => { const { container } = render(hello world, { theme: { Dialog: { Footer: { styles: { base: { backgroundColor: 'red' } } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Dialog.IconWrapper.base should render correctly', () => { const { container } = render(hello world, { theme: { Dialog: { IconWrapper: { styles: { base: { backgroundColor: 'red' } } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Dialog.Close.base should render correctly', () => { const { container } = render(hello world, { theme: { Dialog: { Close: { styles: { base: { backgroundColor: 'red' } } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); }); describe('defaultProps', () => { it('should render correctly for className', () => { const { container } = render(hello world, { theme: { Dialog: { defaultProps: { className: 'test', color: 'primary' } } }, }); expect(container.firstChild).toMatchSnapshot(); }); });