mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-15 17:31:43 +08:00
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
import { mount } from '@vue/test-utils';
|
|
import Tree from '../index';
|
|
import { calcRangeKeys } from '../util';
|
|
|
|
const TreeNode = Tree.TreeNode;
|
|
|
|
describe('Tree util', () => {
|
|
it('calc range keys', () => {
|
|
const wrapper = mount({
|
|
render() {
|
|
return (
|
|
<Tree>
|
|
<TreeNode key="0-0">
|
|
<TreeNode key="0-0-0" />
|
|
<TreeNode key="0-0-1" />
|
|
</TreeNode>
|
|
<TreeNode key="0-1">
|
|
<TreeNode key="0-1-0" />
|
|
<TreeNode key="0-1-1" />
|
|
</TreeNode>
|
|
<TreeNode key="0-2">
|
|
<TreeNode key="0-2-0">
|
|
<TreeNode key="0-2-0-0" />
|
|
<TreeNode key="0-2-0-1" />
|
|
<TreeNode key="0-2-0-2" />
|
|
</TreeNode>
|
|
</TreeNode>
|
|
</Tree>
|
|
);
|
|
},
|
|
});
|
|
|
|
const treeWrapper = wrapper.find({ name: 'ATree' });
|
|
const keys = calcRangeKeys(
|
|
treeWrapper.vm.$slots.default,
|
|
['0-0', '0-2', '0-2-0'],
|
|
'0-2-0-1',
|
|
'0-0-0',
|
|
);
|
|
const target = ['0-0-0', '0-0-1', '0-1', '0-2', '0-2-0', '0-2-0-0', '0-2-0-1'];
|
|
expect(keys.sort()).toEqual(target.sort());
|
|
});
|
|
});
|