刘光辉
8 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { describe, expect, it } from 'vitest';
 
import { normalizeTableTreeData } from '../helpers/tableTree';
 
describe('normalizeTableTreeData', () => {
  it('removes empty children from leaf nodes at every level', () => {
    const source = [
      {
        children: [{ children: [], id: 'child' }],
        id: 'parent',
      },
      { children: [], id: 'leaf' },
    ];
 
    expect(normalizeTableTreeData(source)).toEqual([
      {
        children: [{ id: 'child' }],
        id: 'parent',
      },
      { id: 'leaf' },
    ]);
    expect(source[0]?.children?.[0]).toHaveProperty('children', []);
  });
});