MCPcopy Index your code
hub / github.com/jesseduffield/lazygit / TestGetVisualDepthAtIndex

Function TestGetVisualDepthAtIndex

pkg/gui/filetree/node_test.go:10–134  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestGetVisualDepthAtIndex(t *testing.T) {
11 scenarios := []struct {
12 name string
13 files []*models.File
14 showRootItem bool
15 collapsedPaths []string
16 expectedDepths []int // one per visible node, skipping root
17 }{
18 {
19 name: "flat files with root item",
20 files: []*models.File{
21 {Path: "a"},
22 {Path: "b"},
23 },
24 showRootItem: true,
25 // Displayed as:
26 // index 0: ▼ / (depth 0, the "." root dir)
27 // index 1: a (depth 1)
28 // index 2: b (depth 1)
29 expectedDepths: []int{0, 1, 1},
30 },
31 {
32 name: "flat files without root item",
33 files: []*models.File{
34 {Path: "a"},
35 {Path: "b"},
36 },
37 showRootItem: false,
38 // Displayed as:
39 // index 0: a (depth 0)
40 // index 1: b (depth 0)
41 expectedDepths: []int{0, 0},
42 },
43 {
44 name: "nested directories with root item",
45 files: []*models.File{
46 {Path: "dir/a"},
47 {Path: "dir/b"},
48 {Path: "c"},
49 },
50 showRootItem: true,
51 // Displayed as:
52 // index 0: ▼ / (depth 0)
53 // index 4: c (depth 1)
54 // index 1: ▼ dir (depth 1)
55 // index 2: a (depth 2)
56 // index 3: b (depth 2)
57 expectedDepths: []int{0, 1, 1, 2, 2},
58 },
59 {
60 name: "compressed paths with root item",
61 files: []*models.File{
62 {Path: "dir1/dir3/a"},
63 {Path: "dir2/dir4/b"},
64 },
65 showRootItem: true,
66 // Tree compresses dir1/dir3 and dir2/dir4 into single nodes.
67 // Displayed as:

Callers

nothing calls this directly

Calls 6

CollapseMethod · 0.95
BuildTreeFromFilesFunction · 0.85
NodeSortComparatorFunction · 0.85
NewCollapsedPathsFunction · 0.85
GetVisualDepthAtIndexMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected