import * as React from 'react'; import { renderHook } from '@testing-library/react-hooks'; import { Box } from '../../Box'; import { Card } 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 for variant border', () => { const { container } = render(Hello world); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly for variant shadow', () => { const { container } = render(Hello world); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly for a title', () => { const { container } = render(Hello world); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly for a footer', () => { const { container } = render(This is a footer}>Hello world); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly for headerAddon', () => { const { container } = render(This is a footer}>Hello world); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly for standalone', () => { const { container } = render( This is a title 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 Card props', () => { const { result } = renderHook(() => Card.useProps()); expect(result.current).toMatchSnapshot(); }); }); describe('render props', () => { it('should render correctly', () => { const { container } = render({(CardProps) =>
Hello world
}
); expect(container.firstChild).toMatchSnapshot(); }); }); }); describe('overrides', () => { it('Card.styles.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Card.Content.styles.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Card.Header.styles.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Card.Title.styles.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Card.Footer.styles.base should render correctly', () => { const { container } = render( This is a footer} overrides={{ Card: { Footer: { styles: { base: { backgroundColor: 'red' } } } } }} > hello world ); expect(container.firstChild).toMatchSnapshot(); }); }); describe('theming', () => { it('Card.styles.base should render correctly', () => { const { container } = render(hello world, { theme: { Card: { styles: { base: { backgroundColor: 'red' } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Card.Content.styles.base should render correctly', () => { const { container } = render(hello world, { theme: { Card: { Content: { styles: { base: { backgroundColor: 'red' } } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Card.Header.styles.base should render correctly', () => { const { container } = render(hello world, { theme: { Card: { Header: { styles: { base: { backgroundColor: 'red' } } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Card.Title.styles.base should render correctly', () => { const { container } = render(hello world, { theme: { Card: { Title: { styles: { base: { backgroundColor: 'red' } } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('Card.Footer.styles.base should render correctly', () => { const { container } = render(This is a footer}>hello world, { theme: { Card: { Footer: { styles: { base: { backgroundColor: 'red' } } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); }); describe('defaultProps', () => { it('should render correctly for className', () => { const { container } = render(hello world, { theme: { Card: { defaultProps: { className: 'test' } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly for variant', () => { const { container } = render(hello world, { theme: { Card: { defaultProps: { variant: 'border' } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly for title', () => { const { container } = render(hello world, { theme: { Card: { defaultProps: { title: 'This is a title' } } }, }); expect(container.firstChild).toMatchSnapshot(); }); });