@@ -48,29 +48,14 @@ describe('parseToRgb', () => {
48
48
green : 67 ,
49
49
red : 174 ,
50
50
} )
51
- expect ( parseToRgb ( 'rgb(174 67 255 / 60% )' ) ) . toEqual ( {
51
+ expect ( parseToRgb ( 'rgb(174 67 255 / 0.6 )' ) ) . toEqual ( {
52
52
alpha : 0.6 ,
53
53
blue : 255 ,
54
54
green : 67 ,
55
55
red : 174 ,
56
56
} )
57
57
} )
58
58
59
- it ( 'should parse a rgba color representation with a precise alpha' , ( ) => {
60
- expect ( parseToRgb ( 'rgba(174,67,255,.12345)' ) ) . toEqual ( {
61
- alpha : 0.12345 ,
62
- blue : 255 ,
63
- green : 67 ,
64
- red : 174 ,
65
- } )
66
- expect ( parseToRgb ( 'rgba(174,67,255,12.345%)' ) ) . toEqual ( {
67
- alpha : 0.12345 ,
68
- blue : 255 ,
69
- green : 67 ,
70
- red : 174 ,
71
- } )
72
- } )
73
-
74
59
it ( 'should parse a rgb color representation' , ( ) => {
75
60
expect ( parseToRgb ( 'rgb(174,67,255)' ) ) . toEqual ( {
76
61
blue : 255 ,
@@ -123,7 +108,7 @@ describe('parseToRgb', () => {
123
108
green : 102 ,
124
109
red : 92 ,
125
110
} )
126
- expect ( parseToRgb ( 'hsl(210 10% 40% / 75% )' ) ) . toEqual ( {
111
+ expect ( parseToRgb ( 'hsl(210 10% 40% / 0.75 )' ) ) . toEqual ( {
127
112
alpha : 0.75 ,
128
113
blue : 112 ,
129
114
green : 102 ,
@@ -144,29 +129,14 @@ describe('parseToRgb', () => {
144
129
green : 0 ,
145
130
red : 0 ,
146
131
} )
147
- expect ( parseToRgb ( 'hsl(210 0.5% 0.5% / 100% )' ) ) . toEqual ( {
132
+ expect ( parseToRgb ( 'hsl(210 0.5% 0.5% / 1.0 )' ) ) . toEqual ( {
148
133
alpha : 1 ,
149
134
blue : 0 ,
150
135
green : 0 ,
151
136
red : 0 ,
152
137
} )
153
138
} )
154
139
155
- it ( 'should parse a hsla color representation with a precise alpha' , ( ) => {
156
- expect ( parseToRgb ( 'hsla(210,10%,40%,.12345)' ) ) . toEqual ( {
157
- alpha : 0.12345 ,
158
- blue : 112 ,
159
- green : 102 ,
160
- red : 92 ,
161
- } )
162
- expect ( parseToRgb ( 'hsla(210,10%,40%,12.345%)' ) ) . toEqual ( {
163
- alpha : 0.12345 ,
164
- blue : 112 ,
165
- green : 102 ,
166
- red : 92 ,
167
- } )
168
- } )
169
-
170
140
it ( 'should throw an error if an invalid color string is provided' , ( ) => {
171
141
expect ( ( ) => {
172
142
parseToRgb ( '(174,67,255)' )
@@ -183,38 +153,6 @@ describe('parseToRgb', () => {
183
153
)
184
154
} )
185
155
186
- it ( 'should throw an error if an invalid rgba string is provided' , ( ) => {
187
- const colors = [
188
- 'rgba(174,67,255,)' ,
189
- 'rgba(174,67,255,%)' ,
190
- 'rgba(174,67,255,.)' ,
191
- 'rgba(174,67,255,1.)' ,
192
- ]
193
- colors . forEach ( color => {
194
- expect ( ( ) => {
195
- parseToRgb ( color )
196
- } ) . toThrow (
197
- "Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation." ,
198
- )
199
- } )
200
- } )
201
-
202
- it ( 'should throw an error if an invalid hsla string is provided' , ( ) => {
203
- const colors = [
204
- 'hsla(210,10%,40%,)' ,
205
- 'hsla(210,10%,40%,%)' ,
206
- 'hsla(210,10%,40%,.)' ,
207
- 'hsla(210,10%,40%,1.)' ,
208
- ]
209
- colors . forEach ( color => {
210
- expect ( ( ) => {
211
- parseToRgb ( color )
212
- } ) . toThrow (
213
- "Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation." ,
214
- )
215
- } )
216
- } )
217
-
218
156
it ( 'should throw an error if an invalid hsl string is provided' , ( ) => {
219
157
expect ( ( ) => {
220
158
parseToRgb ( 'hsl(210,120%,4%)' )
0 commit comments