Skip to content

Commit

Permalink
test: cover new style options
Browse files Browse the repository at this point in the history
  • Loading branch information
dundee committed Dec 29, 2024
1 parent a6fc922 commit 2c8c1a4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
14 changes: 14 additions & 0 deletions cmd/gdu/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,20 @@ func TestAnalyzePathWithStyle(t *testing.T) {
ProgressModal: ProgressModalOpts{
CurrentItemNameMaxLen: 10,
},
Footer: FooterColorStyle{
TextColor: "black",
BackgroundColor: "red",
NumberColor: "white",
},
Header: HeaderColorStyle{
TextColor: "black",
BackgroundColor: "red",
Hidden: true,
},
ResultRow: ResultRowColorStyle{
NumberColor: "orange",
DirectoryColor: "blue",
},
UseOldSizeBar: true,
},
},
Expand Down
36 changes: 23 additions & 13 deletions tui/tui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,28 +700,38 @@ func TestMin(t *testing.T) {
assert.Equal(t, 3, min(4, 3))
}

func TestSetSelectedBackgroundColor(t *testing.T) {
func TestSetStyles(t *testing.T) {
simScreen := testapp.CreateSimScreen()
defer simScreen.Fini()

app := testapp.CreateMockedApp(true)
ui := CreateUI(app, simScreen, &bytes.Buffer{}, false, true, false, false, false)

ui.SetSelectedBackgroundColor(tcell.ColorRed)

assert.Equal(t, ui.selectedBackgroundColor, tcell.ColorRed)
}

func TestSetSelectedTextColor(t *testing.T) {
simScreen := testapp.CreateSimScreen()
defer simScreen.Fini()
opts := []Option{}
opts = append(opts, func(ui *UI) {
ui.SetHeaderHidden()
})

app := testapp.CreateMockedApp(true)
ui := CreateUI(app, simScreen, &bytes.Buffer{}, false, true, false, false, false)
ui := CreateUI(app, simScreen, &bytes.Buffer{}, false, true, false, false, false, opts...)

ui.SetSelectedBackgroundColor(tcell.ColorRed)
ui.SetSelectedTextColor(tcell.ColorRed)
ui.SetFooterTextColor("red")
ui.SetFooterBackgroundColor("red")
ui.SetFooterNumberColor("red")
ui.SetHeaderTextColor("red")
ui.SetHeaderBackgroundColor("red")
ui.SetResultRowDirectoryColor("red")
ui.SetResultRowNumberColor("red")

assert.Equal(t, ui.selectedBackgroundColor, tcell.ColorRed)
assert.Equal(t, ui.selectedTextColor, tcell.ColorRed)
assert.Equal(t, ui.footerTextColor, "red")
assert.Equal(t, ui.footerBackgroundColor, "red")
assert.Equal(t, ui.footerNumberColor, "red")
assert.Equal(t, ui.headerTextColor, "red")
assert.Equal(t, ui.headerBackgroundColor, "red")
assert.Equal(t, ui.headerHidden, true)
assert.Equal(t, ui.resultRow.DirectoryColor, "red")
assert.Equal(t, ui.resultRow.NumberColor, "red")
}

func TestSetCurrentItemNameMaxLen(t *testing.T) {
Expand Down

0 comments on commit 2c8c1a4

Please sign in to comment.