mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-18 11:18:14 +08:00
fdbf37a9c0
* test: increase test case of Cascader * test: increase test case of Grid and Tree
58 lines
2.0 KiB
JavaScript
58 lines
2.0 KiB
JavaScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import Tree from '../index';
|
|
|
|
const { TreeNode } = Tree;
|
|
|
|
describe('Tree', () => {
|
|
it('icon and switcherIcon of Tree with showLine should render correctly', () => {
|
|
const wrapper = mount(
|
|
<Tree showLine showIcon>
|
|
<TreeNode icon="icon" switcherIcon="switcherIcon" key="0-0">
|
|
<TreeNode icon="icon" switcherIcon="switcherIcon" key="0-0-0" />
|
|
<TreeNode switcherIcon="switcherIcon" key="0-0-1" />
|
|
<TreeNode icon="icon" key="0-0-2" />
|
|
<TreeNode key="0-0-3" />
|
|
</TreeNode>
|
|
<TreeNode switcherIcon="switcherIcon" key="0-1">
|
|
<TreeNode icon="icon" switcherIcon="switcherIcon" key="0-0-0" />
|
|
<TreeNode switcherIcon="switcherIcon" key="0-0-1" />
|
|
<TreeNode icon="icon" key="0-0-2" />
|
|
<TreeNode key="0-0-3" />
|
|
</TreeNode>
|
|
<TreeNode key="0-2">
|
|
<TreeNode icon="icon" switcherIcon="switcherIcon" key="0-0-0" />
|
|
<TreeNode switcherIcon="switcherIcon" key="0-0-1" />
|
|
<TreeNode icon="icon" key="0-0-2" />
|
|
<TreeNode key="0-0-3" />
|
|
</TreeNode>
|
|
</Tree>,
|
|
);
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
});
|
|
|
|
it('switcherIcon in Tree should not render at leaf nodes', () => {
|
|
const wrapper = mount(
|
|
<Tree switcherIcon={<i className="switcherIcon" />} defaultExpandAll>
|
|
<TreeNode icon="icon">
|
|
<TreeNode id="node1" title="node1" icon="icon" key="0-0-2" />
|
|
<TreeNode id="node2" title="node2" key="0-0-3" />
|
|
</TreeNode>
|
|
</Tree>,
|
|
);
|
|
expect(wrapper.find('.switcherIcon').length).toBe(1);
|
|
});
|
|
|
|
it('switcherIcon in Tree could be string', () => {
|
|
const wrapper = mount(
|
|
<Tree switcherIcon="switcherIcon" defaultExpandAll>
|
|
<TreeNode icon="icon">
|
|
<TreeNode id="node1" title="node1" icon="icon" key="0-0-2" />
|
|
<TreeNode id="node2" title="node2" key="0-0-3" />
|
|
</TreeNode>
|
|
</Tree>,
|
|
);
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
});
|
|
});
|