diff --git a/src/lib/vbranches/filetree.test.ts b/src/lib/vbranches/filetree.test.ts index 311298f31..0dbcc6cc8 100644 --- a/src/lib/vbranches/filetree.test.ts +++ b/src/lib/vbranches/filetree.test.ts @@ -37,16 +37,20 @@ test('creates a file tree', () => { }) ]; const fileTree = filesToFileTree(files); - expect(fileTree).toHaveLength(2); + const children = fileTree.children; + expect(children).toHaveLength(2); - expect(fileTree[0].name).toEqual('test'); - expect(fileTree[0].children[0].name).toEqual('foo.py'); - expect(fileTree[0].children[0].file).toEqual(files[0]); - expect(fileTree[0].children[1].name).toEqual('bar.rs'); - expect(fileTree[0].children[1].file).toEqual(files[1]); + // Note that the result is sorted + // - folders first + // - then alphanumerically + expect(children[1].name).toEqual('test'); + expect(children[1].children[0].name).toEqual('bar.rs'); + expect(children[1].children[0].file).toEqual(files[1]); + expect(children[1].children[1].name).toEqual('foo.py'); + expect(children[1].children[1].file).toEqual(files[0]); - expect(fileTree[1].name).toEqual('src'); - expect(fileTree[1].children[0].name).toEqual('hello'); - expect(fileTree[1].children[0].children[0].name).toEqual('world.txt'); - expect(fileTree[1].children[0].children[0].file).toEqual(files[2]); + expect(children[0].name).toEqual('src'); + expect(children[0].children[0].name).toEqual('hello'); + expect(children[0].children[0].children[0].name).toEqual('world.txt'); + expect(children[0].children[0].children[0].file).toEqual(files[2]); }); diff --git a/src/lib/vbranches/filetree.ts b/src/lib/vbranches/filetree.ts index 2fa1614f2..3c8af8afc 100644 --- a/src/lib/vbranches/filetree.ts +++ b/src/lib/vbranches/filetree.ts @@ -25,9 +25,7 @@ function createNode(acc: TreeNode, pathParts: string[]) { } export function sortChildren(node: TreeNode) { - console.log(node.name); node.children.sort((a, b) => { - console.log(a.file, b.file); if (a.file && !b.file) { return 1; } else if (!a.file && b.file) {