import * as React from 'react'; import renderer from 'react-test-renderer'; import MDResultPage, { IMDResultPageButtonSet as ButtonProps, MDResultPageStyles, MDResultPageType, } from '../index'; const ResultPageType = ['empty', 'lost', 'network']; it('renders correctly with defaults', () => { for (const key in ResultPageType) { if (key) { const component = renderer .create() .toJSON(); expect(component).toMatchSnapshot(); } } }); it('renders correctly with not exists type', () => { const component = renderer .create() .toJSON(); expect(component).toMatchSnapshot(); const otherComponent = renderer .create( ) .toJSON(); expect(component).toMatchSnapshot(); }); it('renders correctly with empty type', () => { const component = renderer .create() .toJSON(); expect(component).toMatchSnapshot(); }); it('renders correctly with custom text and subtext', () => { const component = renderer .create() .toJSON(); expect(component).toMatchSnapshot(); }); it('renders correctly with custom image', () => { const component = renderer .create( ) .toJSON(); expect(component).toMatchSnapshot(); }); it('renders correctly with custom buttons', () => { const firstButton: ButtonProps = { type: 'primary', text: '刷新试试', handler: () => console.log('refresh'), }; const secondButton: ButtonProps = { type: 'default', text: '返回试试', handler: () => console.log('back'), }; const imgUrl = 'https://manhattan.didistatic.com/static/manhattan/mand-mobile/result-page/2.0/empty.png'; const styles = { ...MDResultPageStyles, buttonWrapper: { marginHorizontal: 10, }, }; const component = renderer .create( ) .toJSON(); expect(component).toMatchSnapshot(); const component2 = renderer .create( ) .toJSON(); expect(component2).toMatchSnapshot(); });