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

Function TestGetTextStyle

pkg/theme/style_test.go:11–57  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestGetTextStyle(t *testing.T) {
12 scenarios := []struct {
13 name string
14 keys []string
15 background bool
16 expected style.TextStyle
17 }{
18 {
19 name: "empty",
20 keys: []string{""},
21 background: true,
22 expected: style.New(),
23 },
24 {
25 name: "named color, fg",
26 keys: []string{"blue"},
27 background: false,
28 expected: style.New().SetFg(style.NewBasicColor(color.FgBlue)),
29 },
30 {
31 name: "named color, bg",
32 keys: []string{"blue"},
33 background: true,
34 expected: style.New().SetBg(style.NewBasicColor(color.BgBlue)),
35 },
36 {
37 name: "hex color, fg",
38 keys: []string{"#123456"},
39 background: false,
40 expected: style.New().SetFg(style.NewRGBColor(color.RGBColor{0x12, 0x34, 0x56, 0})),
41 },
42 {
43 name: "hex color, bg",
44 keys: []string{"#abcdef"},
45 background: true,
46 expected: style.New().SetBg(style.NewRGBColor(color.RGBColor{0xab, 0xcd, 0xef, 1})),
47 },
48 }
49
50 for _, scenario := range scenarios {
51 t.Run(scenario.name, func(t *testing.T) {
52 if actual := GetTextStyle(scenario.keys, scenario.background); !reflect.DeepEqual(actual, scenario.expected) {
53 t.Errorf("GetTextStyle() = %v, expected %v", actual, scenario.expected)
54 }
55 })
56 }
57}

Callers

nothing calls this directly

Calls 8

NewFunction · 0.92
NewBasicColorFunction · 0.92
NewRGBColorFunction · 0.92
GetTextStyleFunction · 0.85
SetFgMethod · 0.80
SetBgMethod · 0.80
ErrorfMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected