ant-design/components/tree/__tests__/util.test.js
二货机器人 451d01b082
fix: refactor collect tree key code logic (#19646)
* fix: collect tree key should support nest chldren

* fix logic

* update snapshot
2019-11-09 22:33:53 +08:00

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