MCPcopy
hub / github.com/jesseduffield/lazygit / TestRenderFileTree

Function TestRenderFileTree

pkg/gui/presentation/files_test.go:22–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20}
21
22func TestRenderFileTree(t *testing.T) {
23 scenarios := []struct {
24 name string
25 root *filetree.FileNode
26 files []*models.File
27 collapsedPaths []string
28 showLineChanges bool
29 showRootItem bool
30 expected []string
31 }{
32 {
33 name: "nil node",
34 files: nil,
35 expected: []string{},
36 },
37 {
38 name: "leaf node",
39 files: []*models.File{
40 {Path: "test", ShortStatus: " M", HasStagedChanges: true},
41 },
42 showRootItem: true,
43 expected: []string{" M test"},
44 },
45 {
46 name: "numstat",
47 files: []*models.File{
48 {Path: "test", ShortStatus: " M", HasStagedChanges: true, LinesAdded: 1, LinesDeleted: 1},
49 {Path: "test2", ShortStatus: " M", HasStagedChanges: true, LinesAdded: 1},
50 {Path: "test3", ShortStatus: " M", HasStagedChanges: true, LinesDeleted: 1},
51 {Path: "test4", ShortStatus: " M", HasStagedChanges: true, LinesAdded: 0, LinesDeleted: 0},
52 },
53 showLineChanges: true,
54 showRootItem: true,
55 expected: []string{
56 "▼ /",
57 " M test +1 -1",
58 " M test2 +1",
59 " M test3 -1",
60 " M test4",
61 },
62 },
63 {
64 name: "big example",
65 files: []*models.File{
66 {Path: "dir1/file2", ShortStatus: "M ", HasUnstagedChanges: true},
67 {Path: "dir1/file3", ShortStatus: "M ", HasUnstagedChanges: true},
68 {Path: "dir2/dir2/file3", ShortStatus: " M", HasStagedChanges: true},
69 {Path: "dir2/dir2/file4", ShortStatus: "M ", HasUnstagedChanges: true},
70 {Path: "dir2/file5", ShortStatus: "M ", HasUnstagedChanges: true},
71 {Path: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
72 },
73 showRootItem: true,
74 expected: toStringSlice(
75 `
76▼ /
77 ▶ dir1
78 ▼ dir2
79 ▼ dir2

Callers

nothing calls this directly

Calls 7

SetTreeMethod · 0.95
ToggleCollapsedMethod · 0.95
NewFileTreeFunction · 0.92
toStringSliceFunction · 0.85
RenderFileTreeFunction · 0.85
UserConfigMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected