@@ -48,29 +48,14 @@ describe('parseToRgb', () => {
4848 green : 67 ,
4949 red : 174 ,
5050 } )
51- expect ( parseToRgb ( 'rgb(174 67 255 / 60% )' ) ) . toEqual ( {
51+ expect ( parseToRgb ( 'rgb(174 67 255 / 0.6 )' ) ) . toEqual ( {
5252 alpha : 0.6 ,
5353 blue : 255 ,
5454 green : 67 ,
5555 red : 174 ,
5656 } )
5757 } )
5858
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-
7459 it ( 'should parse a rgb color representation' , ( ) => {
7560 expect ( parseToRgb ( 'rgb(174,67,255)' ) ) . toEqual ( {
7661 blue : 255 ,
@@ -123,7 +108,7 @@ describe('parseToRgb', () => {
123108 green : 102 ,
124109 red : 92 ,
125110 } )
126- expect ( parseToRgb ( 'hsl(210 10% 40% / 75% )' ) ) . toEqual ( {
111+ expect ( parseToRgb ( 'hsl(210 10% 40% / 0.75 )' ) ) . toEqual ( {
127112 alpha : 0.75 ,
128113 blue : 112 ,
129114 green : 102 ,
@@ -144,29 +129,14 @@ describe('parseToRgb', () => {
144129 green : 0 ,
145130 red : 0 ,
146131 } )
147- expect ( parseToRgb ( 'hsl(210 0.5% 0.5% / 100% )' ) ) . toEqual ( {
132+ expect ( parseToRgb ( 'hsl(210 0.5% 0.5% / 1.0 )' ) ) . toEqual ( {
148133 alpha : 1 ,
149134 blue : 0 ,
150135 green : 0 ,
151136 red : 0 ,
152137 } )
153138 } )
154139
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-
170140 it ( 'should throw an error if an invalid color string is provided' , ( ) => {
171141 expect ( ( ) => {
172142 parseToRgb ( '(174,67,255)' )
@@ -183,38 +153,6 @@ describe('parseToRgb', () => {
183153 )
184154 } )
185155
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-
218156 it ( 'should throw an error if an invalid hsl string is provided' , ( ) => {
219157 expect ( ( ) => {
220158 parseToRgb ( 'hsl(210,120%,4%)' )
0 commit comments