mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-27 17:52:16 +00:00
[TS] Use custom TreeNode type (#3164)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { TreeNode } from 'primevue/treenode'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { TreeNode } from '@/types/treeExplorerTypes'
|
||||
import { buildTree, sortedTree } from '@/utils/treeUtil'
|
||||
|
||||
describe('buildTree', () => {
|
||||
@@ -84,6 +84,7 @@ describe('sortedTree', () => {
|
||||
const node: TreeNode = {
|
||||
key: 'root',
|
||||
label: 'root',
|
||||
leaf: false,
|
||||
children: [createNode('c'), createNode('a'), createNode('b')]
|
||||
}
|
||||
|
||||
@@ -91,21 +92,6 @@ describe('sortedTree', () => {
|
||||
expect(result.children?.map((c) => c.label)).toEqual(['a', 'b', 'c'])
|
||||
})
|
||||
|
||||
it('should handle undefined labels', () => {
|
||||
const node: TreeNode = {
|
||||
key: 'root',
|
||||
label: 'root',
|
||||
children: [
|
||||
{ key: '1', label: 'b' },
|
||||
{ key: '2', label: 'a' },
|
||||
{ key: '3', label: undefined }
|
||||
]
|
||||
}
|
||||
|
||||
const result = sortedTree(node)
|
||||
expect(result.children?.map((c) => c.label)).toEqual([undefined, 'a', 'b'])
|
||||
})
|
||||
|
||||
describe('with groupLeaf=true', () => {
|
||||
it('should group folders before files', () => {
|
||||
const node: TreeNode = {
|
||||
|
||||
Reference in New Issue
Block a user