@@ -8,50 +8,97 @@ import (
8
8
"github.com/stretchr/testify/assert"
9
9
)
10
10
11
- func TestANSIColorCodeString (t * testing.T ) {
11
+ // TestGlamourStyleColors ensures that the resulting string color codes match the expected values.
12
+ func TestGlamourStyleColors (t * testing.T ) {
12
13
tests := []struct {
13
14
name string
14
- c ANSIColorCode
15
+ c glamourStyleColor
15
16
want string
16
17
}{
18
+ {
19
+ name : "black" ,
20
+ c : black ,
21
+ want : "0" ,
22
+ },
17
23
{
18
24
name : "red" ,
19
- c : Red ,
25
+ c : red ,
20
26
want : "1" ,
21
27
},
28
+ {
29
+ name : "green" ,
30
+ c : green ,
31
+ want : "2" ,
32
+ },
33
+ {
34
+ name : "yellow" ,
35
+ c : yellow ,
36
+ want : "3" ,
37
+ },
38
+ {
39
+ name : "blue" ,
40
+ c : blue ,
41
+ want : "4" ,
42
+ },
43
+ {
44
+ name : "magenta" ,
45
+ c : magenta ,
46
+ want : "5" ,
47
+ },
48
+ {
49
+ name : "cyan" ,
50
+ c : cyan ,
51
+ want : "6" ,
52
+ },
53
+ {
54
+ name : "white" ,
55
+ c : white ,
56
+ want : "7" ,
57
+ },
58
+ {
59
+ name : "bright black" ,
60
+ c : brightBlack ,
61
+ want : "8" ,
62
+ },
22
63
{
23
64
name : "bright red" ,
24
- c : BrightRed ,
65
+ c : brightRed ,
25
66
want : "9" ,
26
67
},
27
- }
28
- for _ , tt := range tests {
29
- t .Run (tt .name , func (t * testing.T ) {
30
- assert .Equal (t , tt .want , tt .c .String ())
31
- })
32
- }
33
- }
34
-
35
- func TestANSIColorCodeStrPtr (t * testing.T ) {
36
- tests := []struct {
37
- name string
38
- c ANSIColorCode
39
- want * string
40
- }{
41
68
{
42
- name : "green" ,
43
- c : Green ,
44
- want : strPtr ( "2" ) ,
69
+ name : "bright green" ,
70
+ c : brightGreen ,
71
+ want : "10" ,
45
72
},
46
73
{
47
- name : "bright green" ,
48
- c : BrightGreen ,
49
- want : strPtr ("10" ),
74
+ name : "bright yellow" ,
75
+ c : brightYellow ,
76
+ want : "11" ,
77
+ },
78
+ {
79
+ name : "bright blue" ,
80
+ c : brightBlue ,
81
+ want : "12" ,
82
+ },
83
+ {
84
+ name : "bright magenta" ,
85
+ c : brightMagenta ,
86
+ want : "13" ,
87
+ },
88
+ {
89
+ name : "bright cyan" ,
90
+ c : brightCyan ,
91
+ want : "14" ,
92
+ },
93
+ {
94
+ name : "bright white" ,
95
+ c : brightWhite ,
96
+ want : "15" ,
50
97
},
51
98
}
52
99
for _ , tt := range tests {
53
100
t .Run (tt .name , func (t * testing.T ) {
54
- assert .Equal (t , tt .want , tt .c .StrPtr ())
101
+ assert .Equal (t , tt .want , * tt .c .Code ())
55
102
})
56
103
}
57
104
}
@@ -87,31 +134,31 @@ func TestAccessibleStyleConfig(t *testing.T) {
87
134
88
135
func Test_accessibleDarkStyleConfig (t * testing.T ) {
89
136
cfg := accessibleDarkStyleConfig ()
90
- assert .Equal (t , White . StrPtr (), cfg .Document .StylePrimitive .Color )
91
- assert .Equal (t , BrightCyan . StrPtr (), cfg .Link .Color )
92
- assert .Equal (t , BrightMagenta . StrPtr (), cfg .Heading .StylePrimitive .Color )
93
- assert .Equal (t , BrightWhite . StrPtr (), cfg .H1 .StylePrimitive .Color )
94
- assert .Equal (t , BrightBlue . StrPtr (), cfg .H1 .StylePrimitive .BackgroundColor )
95
- assert .Equal (t , BrightWhite . StrPtr (), cfg .Code .BackgroundColor )
96
- assert .Equal (t , Red . StrPtr (), cfg .Code .Color )
97
- assert .Equal (t , BrightMagenta . StrPtr (), cfg .Image .Color )
98
- assert .Equal (t , White . StrPtr (), cfg .HorizontalRule .Color )
137
+ assert .Equal (t , white . Code (), cfg .Document .StylePrimitive .Color )
138
+ assert .Equal (t , brightCyan . Code (), cfg .Link .Color )
139
+ assert .Equal (t , brightMagenta . Code (), cfg .Heading .StylePrimitive .Color )
140
+ assert .Equal (t , brightWhite . Code (), cfg .H1 .StylePrimitive .Color )
141
+ assert .Equal (t , brightBlue . Code (), cfg .H1 .StylePrimitive .BackgroundColor )
142
+ assert .Equal (t , brightWhite . Code (), cfg .Code .BackgroundColor )
143
+ assert .Equal (t , red . Code (), cfg .Code .Color )
144
+ assert .Equal (t , brightMagenta . Code (), cfg .Image .Color )
145
+ assert .Equal (t , white . Code (), cfg .HorizontalRule .Color )
99
146
100
147
// Test that we haven't changed the original style
101
148
assert .Equal (t , styles .DarkStyleConfig .H2 , cfg .H2 )
102
149
}
103
150
104
151
func Test_accessibleLightStyleConfig (t * testing.T ) {
105
152
cfg := accessibleLightStyleConfig ()
106
- assert .Equal (t , Black . StrPtr (), cfg .Document .StylePrimitive .Color )
107
- assert .Equal (t , BrightBlue . StrPtr (), cfg .Link .Color )
108
- assert .Equal (t , Magenta . StrPtr (), cfg .Heading .StylePrimitive .Color )
109
- assert .Equal (t , BrightWhite . StrPtr (), cfg .H1 .StylePrimitive .Color )
110
- assert .Equal (t , Blue . StrPtr (), cfg .H1 .StylePrimitive .BackgroundColor )
111
- assert .Equal (t , BrightWhite . StrPtr (), cfg .Code .BackgroundColor )
112
- assert .Equal (t , Red . StrPtr (), cfg .Code .Color )
113
- assert .Equal (t , Magenta . StrPtr (), cfg .Image .Color )
114
- assert .Equal (t , White . StrPtr (), cfg .HorizontalRule .Color )
153
+ assert .Equal (t , black . Code (), cfg .Document .StylePrimitive .Color )
154
+ assert .Equal (t , brightBlue . Code (), cfg .Link .Color )
155
+ assert .Equal (t , magenta . Code (), cfg .Heading .StylePrimitive .Color )
156
+ assert .Equal (t , brightWhite . Code (), cfg .H1 .StylePrimitive .Color )
157
+ assert .Equal (t , blue . Code (), cfg .H1 .StylePrimitive .BackgroundColor )
158
+ assert .Equal (t , brightWhite . Code (), cfg .Code .BackgroundColor )
159
+ assert .Equal (t , red . Code (), cfg .Code .Color )
160
+ assert .Equal (t , magenta . Code (), cfg .Image .Color )
161
+ assert .Equal (t , white . Code (), cfg .HorizontalRule .Color )
115
162
116
163
// Test that we haven't changed the original style
117
164
assert .Equal (t , styles .LightStyleConfig .H2 , cfg .H2 )
0 commit comments