-
Notifications
You must be signed in to change notification settings - Fork 590
/
Copy pathIcon.test.tsx
35 lines (30 loc) · 1.07 KB
/
Icon.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { TwitterOutlined } from '@ant-design/icons-svg';
import * as React from 'react';
import { mount } from 'enzyme';
import Icon from '../src/components/IconBase';
describe('React AntdIcon Component', () => {
it('should create SVG element.', () => {
const props = {
style: {
fontSize: '3rem',
},
color: 'red',
className: 'my-icon',
extraProps: { hello: 'world' },
} as any;
const icon = mount(
<Icon {...props} />,
);
expect(icon).toMatchSnapshot();
});
it('should allow explicit import.', () => {
const icon = mount(<Icon icon={TwitterOutlined} />);
expect(typeof icon.find('path').first().prop('d')).toBe('string');
});
it('should render null, when the type is invalid.', () => {
const iconWithObjectTypeProp = mount(<Icon icon={{ invalid: true } as any} />);
expect(iconWithObjectTypeProp.isEmptyRender()).toBeTruthy();
const iconWithStringTypeProp = mount(<Icon icon={'Later is better than never.' as any} />);
expect(iconWithStringTypeProp.isEmptyRender()).toBeTruthy();
});
});