mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 03:29:39 +08:00
c34caad24c
* test: js => ts * test: add test * fix: fix eslint error * test: add test case * fix: fix test error * fix: fix eslint error * fix: fix eslint error * fix: eslint error fix * fix: fallback eslint config & add test case * test: add all test case * fix: bugfix * fix: bugFix * fix: bugFix * fix: bugFix * fix: lint * fix: add React.createRef * fix: add breadcrumbName in Routes * fix: any commit for restart ci/cd * fix: remove type * fix: test fix * fix: test fix * fix: add ts-ignore for id * test: add Icon test case * test: remove ts-ignore * test: add Icon test case
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { calcRangeKeys } from '../utils/dictUtil';
|
|
|
|
describe('Tree util', () => {
|
|
describe('calcRangeKeys', () => {
|
|
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' }] },
|
|
],
|
|
},
|
|
];
|
|
|
|
it('calc range keys', () => {
|
|
const rangeKeys = calcRangeKeys({
|
|
treeData,
|
|
expandedKeys: ['0-0', '0-2', '0-2-0'],
|
|
startKey: '0-2-0-1',
|
|
endKey: '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(rangeKeys.sort()).toEqual(target.sort());
|
|
});
|
|
|
|
it('return startKey when startKey === endKey', () => {
|
|
const keys = calcRangeKeys({
|
|
treeData,
|
|
expandedKeys: ['0-0', '0-2', '0-2-0'],
|
|
startKey: '0-0-0',
|
|
endKey: '0-0-0',
|
|
});
|
|
expect(keys).toEqual(['0-0-0']);
|
|
});
|
|
|
|
it('return empty array without startKey and endKey', () => {
|
|
const keys = calcRangeKeys({
|
|
treeData,
|
|
expandedKeys: ['0-0', '0-2', '0-2-0'],
|
|
});
|
|
expect(keys).toEqual([]);
|
|
});
|
|
});
|
|
});
|