mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-06 02:15:35 +08:00
451d01b082
* fix: collect tree key should support nest chldren * fix logic * update snapshot
21 lines
682 B
JavaScript
21 lines
682 B
JavaScript
import { calcRangeKeys } from '../utils/dictUtil';
|
|
|
|
describe('Tree util', () => {
|
|
it('calc range keys', () => {
|
|
const treeData = [
|
|
{ key: '0-0', children: [{ key: '0-0-0' }, { key: '0-0-1' }] },
|
|
{ key: '0-1', children: [{ key: '0-1-0' }, { key: '0-1-1' }] },
|
|
{
|
|
key: '0-2',
|
|
children: [
|
|
{ key: '0-2-0', children: [{ key: '0-2-0-0' }, { key: '0-2-0-1' }, { key: '0-2-0-2' }] },
|
|
],
|
|
},
|
|
];
|
|
|
|
const keys = calcRangeKeys(treeData, ['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());
|
|
});
|
|
});
|