import React from 'react'; import { render } from 'enzyme'; import Icon from '..'; describe('Icon', () => { it('should render to a ...', () => { const wrapper = render( ); expect(wrapper).toMatchSnapshot(); }); it('should support basic usage', () => { const wrapper = render(
); expect(wrapper).toMatchSnapshot(); }); it('should support older usage', () => { const wrapper = render(
); expect(wrapper).toMatchSnapshot(); }); it('should support two-tone icon', () => { const wrapper = render( ); expect(wrapper).toMatchSnapshot(); }); it('should support config global two-tone primary color', () => { const colors = Icon.getTwoToneColors(); Icon.setTwoToneColors({ primaryColor: '#1890ff', }); const wrapper = render( ); expect(wrapper).toMatchSnapshot(); Icon.setTwoToneColors(colors); }); it('should give a warning when there is no primaryColor but secondaryColor', () => { const wrapper = render( ); expect(wrapper).toMatchSnapshot(); }); it('should support pass svg paths as children', () => { const wrapper = render( Cool Home ); expect(wrapper).toMatchSnapshot(); }); it('should give warning and render {null}', () => { const wrapper = render( ); expect(wrapper).toMatchSnapshot(); }); describe('`component` prop', () => { it('can access to svg defs if has children', () => { const wrapper = render( ( { React.Children.map( svgProps.children, child => React.cloneElement( child, child.type === 'path' ? { fill: 'scriptUrl(#gradient)' } : {} ) ) } )} > Cool Home ); expect(wrapper).toMatchSnapshot(); }); }); it('should support svg react component', () => { const SvgComponent = props => ( Cool Home ); const wrapper = render( Cool Home ); expect(wrapper).toMatchSnapshot(); }); }); describe('Icon.createFromIconfontCN()', () => { const IconFont = Icon.createFromIconfontCN({ scriptUrl: '//at.alicdn.com/t/font_8d5l8fzk5b87iudi.js', }); it('should support iconfont.cn', () => { const wrapper = render(
); expect(wrapper).toMatchSnapshot(); }); });