fix(#19132): add test file

This commit is contained in:
kavin 2019-10-11 17:31:14 +08:00 committed by 偏右
parent a0851cdd34
commit e161a2ae76

View File

@ -1,7 +1,7 @@
import React from 'react';
import { mount } from 'enzyme';
import Tree from '../index';
import { calcRangeKeys } from '../util';
import { calcRangeKeys, getFullKeyListByTreeData } from '../util';
const { TreeNode } = Tree;
@ -32,4 +32,51 @@ describe('Tree util', () => {
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());
});
it('calc range keys by treeData', () => {
const treeData = [
{
key: '0-0-0',
title: 'Folder',
children: [
{
title: 'Folder2',
key: '0-0-1',
children: [
{
title: 'File',
key: '0-0-2',
isLeaf: true,
},
],
},
],
},
{
key: '0-0-3',
title: 'Folder',
children: [
{
title: 'File',
key: '0-0-4',
isLeaf: true,
},
{
title: 'File',
key: '0-0-5',
isLeaf: true,
},
{
title: 'File',
key: '0-0-6',
isLeaf: true,
},
],
},
];
const keys = getFullKeyListByTreeData(treeData);
const target = ['0-0-0', '0-0-1', '0-0-2', '0-0-3', '0-0-4', '0-0-5', '0-0-6'];
expect(keys.sort()).toEqual(target.sort());
});
});