forked from alibaba-fusion/next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index-spec.js
51 lines (41 loc) · 1.5 KB
/
index-spec.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from 'react';
import Enzyme, { mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import assert from 'power-assert';
import Icon from '../../src/icon';
Enzyme.configure({ adapter: new Adapter() });
describe('Icon', () => {
let wrapper;
beforeEach(() => {
wrapper = mount(<Icon />);
});
afterEach(() => {
wrapper.unmount();
wrapper = null;
});
it('should have type class', () => {
wrapper.setProps({ type: 'comments' });
assert(wrapper.find('.next-icon').hasClass('next-icon-comments'));
});
it('should have size class', () => {
wrapper.setProps({ size: 'large' });
assert(wrapper.find('.next-icon').hasClass('next-large'));
});
it('should receive className prop', () => {
wrapper.setProps({ className: 'custom' });
assert(wrapper.find('.next-icon').hasClass('custom'));
});
it('should receive style prop', () => {
wrapper.setProps({ style: { color: 'red' } });
assert(wrapper.find('.next-icon').prop('style').color === 'red');
});
it('should receive style prop', () => {
const CustomIcon = Icon.createFromIconfontCN({
scriptUrl: '//at.alicdn.com/t/font_1464085_egnk4s8yv2f.js',
});
const newWrapper = mount(<CustomIcon type="icon-pic"/>);
assert(newWrapper.find('.next-icon svg'));
newWrapper.setProps({ size: 'xl' });
assert(newWrapper.find('.next-icon').hasClass('next-xl'));
});
});