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

Function TestRenderCommitFileTree

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

Source from the content-addressed store, hash-verified

130}
131
132func TestRenderCommitFileTree(t *testing.T) {
133 scenarios := []struct {
134 name string
135 root *filetree.FileNode
136 files []*models.CommitFile
137 collapsedPaths []string
138 showRootItem bool
139 expected []string
140 }{
141 {
142 name: "nil node",
143 files: nil,
144 expected: []string{},
145 },
146 {
147 name: "leaf node",
148 files: []*models.CommitFile{
149 {Path: "test", ChangeStatus: "A"},
150 },
151 showRootItem: true,
152 expected: []string{"A test"},
153 },
154 {
155 name: "big example",
156 files: []*models.CommitFile{
157 {Path: "dir1/file2", ChangeStatus: "M"},
158 {Path: "dir1/file3", ChangeStatus: "A"},
159 {Path: "dir2/dir2/file3", ChangeStatus: "D"},
160 {Path: "dir2/dir2/file4", ChangeStatus: "M"},
161 {Path: "dir2/file5", ChangeStatus: "M"},
162 {Path: "file1", ChangeStatus: "M"},
163 },
164 showRootItem: true,
165 expected: toStringSlice(
166 `
167▼ /
168 ▶ dir1
169 ▼ dir2
170 ▼ dir2
171 D file3
172 M file4
173 M file5
174 M file1
175`,
176 ),
177 collapsedPaths: []string{"./dir1"},
178 },
179 {
180 name: "big example without root item",
181 files: []*models.CommitFile{
182 {Path: "dir1/file2", ChangeStatus: "M"},
183 {Path: "dir1/file3", ChangeStatus: "A"},
184 {Path: "dir2/dir2/file3", ChangeStatus: "D"},
185 {Path: "dir2/dir2/file4", ChangeStatus: "M"},
186 {Path: "dir2/file5", ChangeStatus: "M"},
187 {Path: "file1", ChangeStatus: "M"},
188 },
189 showRootItem: false,

Callers

nothing calls this directly

Calls 12

SetRefMethod · 0.95
StartMethod · 0.95
NewCommitFunction · 0.92
NewPatchBuilderFunction · 0.92
NewDummyLogFunction · 0.92
toStringSliceFunction · 0.85
RenderCommitFileTreeFunction · 0.85
UserConfigMethod · 0.80
RunMethod · 0.65
SetTreeMethod · 0.65
ToggleCollapsedMethod · 0.65

Tested by

no test coverage detected