import * as React from 'react'; import { renderHook } from '@testing-library/react-hooks'; import { Callout } 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 tint', () => { 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 a close button and title', () => { 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 with a footer', () => { const { container } = render( Hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with closeButtonProps', () => { const { container } = render( Hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with iconProps', () => { const { container } = render( Hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly for standalone', () => { const { container } = render(
Example callout 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. Test
); 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 Callout props', () => { const { result } = renderHook(() => Callout.useProps()); expect(result.current).toMatchSnapshot(); }); }); describe('render props', () => { it('should render correctly', () => { const { container } = render({(CalloutProps) =>
Hello world
}
); expect(container.firstChild).toMatchSnapshot(); }); }); }); describe('overrides', () => { it('Callout.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Callout.Content.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Callout.Header.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Callout.Title.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Callout.Footer.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Callout.IconWrapper.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Callout.Close.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); }); describe('theming', () => { it('Callout.base should render correctly', () => { const { container } = render(hello world, { theme: { Callout: { styles: { base: { backgroundColor: 'red' } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Callout.Content.base should render correctly', () => { const { container } = render(hello world, { theme: { Callout: { Content: { styles: { base: { backgroundColor: 'red' } } } }, }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Callout.Header.base should render correctly', () => { const { container } = render(hello world, { theme: { Callout: { Header: { styles: { base: { backgroundColor: 'red' } } } }, }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Callout.Title.base should render correctly', () => { const { container } = render(hello world, { theme: { Callout: { Title: { styles: { base: { backgroundColor: 'red' } } } }, }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Callout.Footer.base should render correctly', () => { const { container } = render(hello world, { theme: { Callout: { Footer: { styles: { base: { backgroundColor: 'red' } } } }, }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Callout.IconWrapper.base should render correctly', () => { const { container } = render(hello world, { theme: { Callout: { IconWrapper: { styles: { base: { backgroundColor: 'red' } } }, }, }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Callout.Close.base should render correctly', () => { const { container } = render(hello world, { theme: { Callout: { Close: { styles: { base: { backgroundColor: 'red' } } } }, }, }); expect(container.firstChild).toMatchSnapshot(); }); }); describe('defaultProps', () => { it('should render correctly for className', () => { const { container } = render(hello world, { theme: { Callout: { defaultProps: { className: 'test', color: 'primary' } }, }, }); expect(container.firstChild).toMatchSnapshot(); }); });