You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/tree/__tests__/util.test.js

44 lines
1.2 KiB

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());
});
});