feat: add makeParent options to addChild

This commit is contained in:
wancat committed 2023-08-21 22:22:01 +08:00
1 parent ba610a3fc5
commit fd26be5e64
3 files changed
+44 -6

No files matched your search

+19
View File
@@ -74,4 +74,23 @@ describe('FileNode', () => {
expect(rootNode.children[1].children.length).toBe(1)
console.log(rootNode.toString())
})
test('adds nested children to the tree with makeParents option', () => {
const file = {
path: '/home/rudeus/test/a/b/c/d/e',
name: 'a',
type: 'file',
discovered: false,
}
rootNode.addChild(file, { makeParents: true })
console.log(rootNode.toString())
let currentNode = rootNode
for (let i = 0; i < 5; i += 1) {
expect(currentNode.children.length).toBe(1)
// eslint-disable-next-line prefer-destructuring
currentNode = currentNode.children[0]
}
})
})