1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
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: "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)
}
})
}
}
|