forked from marcusolsson/tui-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme_test.go
55 lines (51 loc) · 1.08 KB
/
theme_test.go
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
package tui
import (
"testing"
)
var base = Style{Fg: ColorWhite, Bg: ColorBlack, Bold: DecorationOff, Underline: DecorationOff}
var mergeTests = []struct {
test string
chain []Style
want Style
}{
{
test: "zero inherits",
chain: []Style{
base,
Style{},
},
want: base,
},
{
test: "orthogonal inherits",
chain: []Style{
base,
Style{Reverse: DecorationOn},
Style{Bold: DecorationOn},
},
want: Style{Fg: ColorWhite, Bg: ColorBlack, Reverse: DecorationOn, Bold: DecorationOn, Underline: DecorationOff},
},
{
test: "serial inherits",
chain: []Style{
base,
Style{Reverse: DecorationOn, Bold: DecorationOn},
Style{Bold: DecorationOff},
},
want: Style{Fg: ColorWhite, Bg: ColorBlack, Reverse: DecorationOn, Bold: DecorationOff, Underline: DecorationOff},
},
}
func TestStyle_Merge(t *testing.T) {
for _, tt := range mergeTests {
tt := tt
t.Run(tt.test, func(t *testing.T) {
var got Style
for _, s := range tt.chain {
got = got.mergeIn(s)
}
if got != tt.want {
t.Errorf("got = \n%v\nwant = \n%v", got, tt.want)
}
})
}
}