forked from charmbracelet/lipgloss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
color_test.go
53 lines (48 loc) · 966 Bytes
/
color_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
package lipgloss
import (
"testing"
"github.com/muesli/termenv"
)
func TestSetColorProfile(t *testing.T) {
t.Parallel()
tt := []struct {
profile termenv.Profile
input string
style Style
expected string
}{
{
termenv.Ascii,
"hello",
NewStyle().Foreground(Color("#5A56E0")),
"hello",
},
{
termenv.ANSI,
"hello",
NewStyle().Foreground(Color("#5A56E0")),
"\x1b[94mhello\x1b[0m",
},
{
termenv.ANSI256,
"hello",
NewStyle().Foreground(Color("#5A56E0")),
"\x1b[38;5;62mhello\x1b[0m",
},
{
termenv.TrueColor,
"hello",
NewStyle().Foreground(Color("#5A56E0")),
"\x1b[38;2;89;86;224mhello\x1b[0m",
},
}
for i, tc := range tt {
SetColorProfile(tc.profile)
res := tc.style.Render(tc.input)
if res != tc.expected {
t.Errorf("Test %d, expected:\n\n`%s`\n`%s`\n\nActual output:\n\n`%s`\n`%s`\n\n",
i, tc.expected, formatEscapes(tc.expected),
res, formatEscapes(res))
}
}
}