import * as React from 'react'; import { renderHook } from '@testing-library/react-hooks'; import { Box } from '../../Box'; import { Stack } from '../Stack'; 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 a horizontal set', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly for a horizontal set with breakpoint', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); ['left', 'right', 'center'].forEach((alignX) => { it(`should render correctly for an alignX of ${alignX}`, () => { const { container } = render( // @ts-ignore hello world ); expect(container.firstChild).toMatchSnapshot(); }); }); ['top', 'bottom', 'center'].forEach((alignY) => { it(`should render correctly for an alignY of ${alignY}`, () => { const { container } = render( // @ts-ignore hello world ); 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 Stack props', () => { const { result } = renderHook(() => Stack.useProps()); expect(result.current).toMatchSnapshot(); }); }); describe('render props', () => { it('should render correctly', () => { const { container } = render( {(StackProps) => (
hello world
)}
); expect(container.firstChild).toMatchSnapshot(); }); }); }); describe('overrides', () => { it('Stack.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Stack.child.base should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Stack.vertical should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Stack.horizontal should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Stack.child.vertical should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); it('Stack.child.horizontal should render correctly', () => { const { container } = render( hello world ); expect(container.firstChild).toMatchSnapshot(); }); }); describe('theming', () => { it('Stack.styles.base should render correctly', () => { const { container } = render( hello world , { theme: { Stack: { styles: { base: { backgroundColor: 'red' } } } }, } ); expect(container.firstChild).toMatchSnapshot(); }); it('Stack.styles.child.base should render correctly', () => { const { container } = render( hello world , { theme: { Stack: { styles: { child: { base: { backgroundColor: 'red' } } } } }, } ); expect(container.firstChild).toMatchSnapshot(); }); it('Stack.styles.vertical should render correctly', () => { const { container } = render( hello world , { theme: { Stack: { styles: { vertical: { backgroundColor: 'red' } } } }, } ); expect(container.firstChild).toMatchSnapshot(); }); it('Stack.styles.horizontal should render correctly', () => { const { container } = render( hello world , { theme: { Stack: { styles: { horizontal: { backgroundColor: 'red' } } } }, } ); expect(container.firstChild).toMatchSnapshot(); }); it('Stack.styles.child.vertical should render correctly', () => { const { container } = render( hello world , { theme: { Stack: { styles: { child: { vertical: { backgroundColor: 'red' } } } } }, } ); expect(container.firstChild).toMatchSnapshot(); }); it('Stack.styles.child.horizontal should render correctly', () => { const { container } = render( hello world , { theme: { Stack: { styles: { child: { horizontal: { backgroundColor: 'red' } } } } }, } ); expect(container.firstChild).toMatchSnapshot(); }); }); describe('defaultProps', () => { it('should render correctly for className', () => { const { container } = render( hello world , { theme: { Stack: { defaultProps: { className: 'test' } } }, } ); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly for orientation', () => { const { container } = render( hello world , { theme: { Stack: { defaultProps: { orientation: 'horizontal' } } }, } ); expect(container.firstChild).toMatchSnapshot(); }); });