2019-05-06 12:04:39 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { mount } from 'enzyme';
|
2019-09-23 18:49:13 +08:00
|
|
|
import TreeSelect, { TreeNode } from '..';
|
2017-11-19 01:41:40 +08:00
|
|
|
import focusTest from '../../../tests/shared/focusTest';
|
2019-08-26 22:53:20 +08:00
|
|
|
import mountTest from '../../../tests/shared/mountTest';
|
2020-01-02 19:10:16 +08:00
|
|
|
import rtlTest from '../../../tests/shared/rtlTest';
|
2017-11-19 01:41:40 +08:00
|
|
|
|
|
|
|
describe('TreeSelect', () => {
|
|
|
|
focusTest(TreeSelect);
|
2019-08-26 22:53:20 +08:00
|
|
|
mountTest(TreeSelect);
|
2020-01-02 19:10:16 +08:00
|
|
|
rtlTest(TreeSelect);
|
2019-05-06 12:04:39 +08:00
|
|
|
|
2019-09-23 18:49:13 +08:00
|
|
|
describe('TreeSelect Custom Icons', () => {
|
|
|
|
it('should support customized icons', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<TreeSelect
|
|
|
|
showSearch
|
|
|
|
clearIcon={<span>clear</span>}
|
|
|
|
removeIcon={<span>remove</span>}
|
|
|
|
value={['leaf1', 'leaf2']}
|
|
|
|
placeholder="Please select"
|
|
|
|
multiple
|
|
|
|
allowClear
|
|
|
|
treeDefaultExpandAll
|
|
|
|
>
|
|
|
|
<TreeNode value="parent 1" title="parent 1" key="0-1">
|
|
|
|
<TreeNode value="parent 1-0" title="parent 1-0" key="0-1-1">
|
|
|
|
<TreeNode value="leaf1" title="my leaf" key="random" />
|
|
|
|
<TreeNode value="leaf2" title="your leaf" key="random1" />
|
|
|
|
</TreeNode>
|
|
|
|
</TreeNode>
|
|
|
|
</TreeSelect>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
2020-03-20 16:03:13 +08:00
|
|
|
|
|
|
|
it('should `treeIcon` work', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<TreeSelect treeIcon open>
|
|
|
|
<TreeNode value="parent 1" title="parent 1" icon={<span>Bamboo</span>} />
|
|
|
|
</TreeSelect>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
2019-09-23 18:49:13 +08:00
|
|
|
});
|
2020-08-26 16:42:47 +08:00
|
|
|
|
|
|
|
it('should support notFoundContent', () => {
|
|
|
|
const wrapper = mount(<TreeSelect treeIcon open notFoundContent="notFoundContent" />);
|
|
|
|
expect(wrapper.text()).toBe('notFoundContent');
|
|
|
|
});
|
2017-11-19 01:41:40 +08:00
|
|
|
});
|