import React from 'react'; import Flex from '..'; import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; import { render } from '../../../tests/utils'; const FunCom = React.forwardRef((props, ref) => (
test FC
)); class ClassCom extends React.PureComponent<{ className?: string }> { render() { return
test Class
; } } describe('Flex', () => { mountTest(() => (
test1
test2
)); rtlTest(() => (
test1
test2
)); it('Flex', () => { const { container, rerender } = render(test); expect(container.querySelector('.ant-flex')).toHaveStyle({ justifyContent: 'center' }); rerender(test); expect(container.querySelector('.ant-flex')).toHaveStyle({ flex: '0 1 auto' }); rerender(test); expect(container.querySelector('.ant-flex')).toHaveStyle({ gap: '100px' }); }); it('Component work', () => { const testFcRef = React.createRef(); const testClsRef = React.createRef(); const { container, rerender } = render(test); expect(container.querySelector('.ant-flex')?.tagName).toBe('DIV'); rerender(test); expect(container.querySelector('.ant-flex')?.tagName).toBe('SPAN'); rerender( }>test); expect(container.querySelector('.ant-flex')?.textContent).toBe('test FC'); expect(testFcRef.current).toBeTruthy(); rerender( }>test); expect(container.querySelector('.ant-flex')?.textContent).toBe('test Class'); expect(testClsRef.current).toBeTruthy(); }); it('when vertical=true should stretch work', () => { const { container, rerender } = render(test); expect(container.querySelector('.ant-flex')).toHaveClass( 'ant-flex-align-stretch', ); rerender( test , ); expect(container.querySelector('.ant-flex')).toHaveClass( 'ant-flex-align-center', ); }); });