mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-05 21:46:49 -04:00
The faint attribute makes text recede on dark and light backgrounds alike, without having to pick a gray for each. Let users use it in the theme. Some theme colors go through both GetTextStyle and GetGocuiStyle, so both have to know it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
64 lines
1.5 KiB
Go
64 lines
1.5 KiB
Go
package theme
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/gookit/color"
|
|
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
|
)
|
|
|
|
func TestGetTextStyle(t *testing.T) {
|
|
scenarios := []struct {
|
|
name string
|
|
keys []string
|
|
background bool
|
|
expected style.TextStyle
|
|
}{
|
|
{
|
|
name: "empty",
|
|
keys: []string{""},
|
|
background: true,
|
|
expected: style.New(),
|
|
},
|
|
{
|
|
name: "named color, fg",
|
|
keys: []string{"blue"},
|
|
background: false,
|
|
expected: style.New().SetFg(style.NewBasicColor(color.FgBlue)),
|
|
},
|
|
{
|
|
name: "named color, bg",
|
|
keys: []string{"blue"},
|
|
background: true,
|
|
expected: style.New().SetBg(style.NewBasicColor(color.BgBlue)),
|
|
},
|
|
{
|
|
name: "hex color, fg",
|
|
keys: []string{"#123456"},
|
|
background: false,
|
|
expected: style.New().SetFg(style.NewRGBColor(color.RGBColor{0x12, 0x34, 0x56, 0})),
|
|
},
|
|
{
|
|
name: "dim",
|
|
keys: []string{"dim"},
|
|
background: false,
|
|
expected: style.New().SetDim(),
|
|
},
|
|
{
|
|
name: "hex color, bg",
|
|
keys: []string{"#abcdef"},
|
|
background: true,
|
|
expected: style.New().SetBg(style.NewRGBColor(color.RGBColor{0xab, 0xcd, 0xef, 1})),
|
|
},
|
|
}
|
|
|
|
for _, scenario := range scenarios {
|
|
t.Run(scenario.name, func(t *testing.T) {
|
|
if actual := GetTextStyle(scenario.keys, scenario.background); !reflect.DeepEqual(actual, scenario.expected) {
|
|
t.Errorf("GetTextStyle() = %v, expected %v", actual, scenario.expected)
|
|
}
|
|
})
|
|
}
|
|
}
|