(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func 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 | } |
nothing calls this directly
no test coverage detected