@@ -58,6 +58,11 @@ describe('parseToHsl', () => {
58
58
lightness : 0.0392156862745098 ,
59
59
saturation : 0.1 ,
60
60
} )
61
+ expect ( parseToHsl ( 'hsl(210deg,10%,4%)' ) ) . toEqual ( {
62
+ hue : 210 ,
63
+ lightness : 0.0392156862745098 ,
64
+ saturation : 0.1 ,
65
+ } )
61
66
} )
62
67
63
68
it ( 'should parse a hsl color representation with a float' , ( ) => {
@@ -66,6 +71,37 @@ describe('parseToHsl', () => {
66
71
lightness : 0.0392156862745098 ,
67
72
saturation : 0.1 ,
68
73
} )
74
+ expect ( parseToHsl ( 'hsl(210.99deg,10%,4%)' ) ) . toEqual ( {
75
+ hue : 210 ,
76
+ lightness : 0.0392156862745098 ,
77
+ saturation : 0.1 ,
78
+ } )
79
+ } )
80
+
81
+ it ( 'should parse a hsl 4 space-separated color representation' , ( ) => {
82
+ expect ( parseToHsl ( 'hsl(210 10% 4%)' ) ) . toEqual ( {
83
+ hue : 210 ,
84
+ lightness : 0.0392156862745098 ,
85
+ saturation : 0.1 ,
86
+ } )
87
+ expect ( parseToHsl ( 'hsl(210deg 10% 4%)' ) ) . toEqual ( {
88
+ hue : 210 ,
89
+ lightness : 0.0392156862745098 ,
90
+ saturation : 0.1 ,
91
+ } )
92
+ } )
93
+
94
+ it ( 'should parse a hsl 4 space-separated color representation with a float' , ( ) => {
95
+ expect ( parseToHsl ( 'hsl(210.99 10% 4%)' ) ) . toEqual ( {
96
+ hue : 210 ,
97
+ lightness : 0.0392156862745098 ,
98
+ saturation : 0.1 ,
99
+ } )
100
+ expect ( parseToHsl ( 'hsl(210.99deg 10% 4%)' ) ) . toEqual ( {
101
+ hue : 210 ,
102
+ lightness : 0.0392156862745098 ,
103
+ saturation : 0.1 ,
104
+ } )
69
105
} )
70
106
71
107
it ( 'should parse a hsla color representation' , ( ) => {
@@ -75,6 +111,12 @@ describe('parseToHsl', () => {
75
111
lightness : 0.4 ,
76
112
saturation : 0.09803921568627451 ,
77
113
} )
114
+ expect ( parseToHsl ( 'hsla(210deg,10%,40%,0.75)' ) ) . toEqual ( {
115
+ alpha : 0.75 ,
116
+ hue : 209.99999999999997 ,
117
+ lightness : 0.4 ,
118
+ saturation : 0.09803921568627451 ,
119
+ } )
78
120
} )
79
121
80
122
it ( 'should parse a hsla color representation with a float' , ( ) => {
@@ -84,6 +126,42 @@ describe('parseToHsl', () => {
84
126
lightness : 0.4 ,
85
127
saturation : 0.09803921568627451 ,
86
128
} )
129
+ expect ( parseToHsl ( 'hsla(210.99deg,10%,40%,0.75)' ) ) . toEqual ( {
130
+ alpha : 0.75 ,
131
+ hue : 209.99999999999997 ,
132
+ lightness : 0.4 ,
133
+ saturation : 0.09803921568627451 ,
134
+ } )
135
+ } )
136
+
137
+ it ( 'should parse a hsla 4 space-separated color representation' , ( ) => {
138
+ expect ( parseToHsl ( 'hsla(210 10% 40% / 0.75)' ) ) . toEqual ( {
139
+ alpha : 0.75 ,
140
+ hue : 209.99999999999997 ,
141
+ lightness : 0.4 ,
142
+ saturation : 0.09803921568627451 ,
143
+ } )
144
+ expect ( parseToHsl ( 'hsla(210deg 10% 40% / 0.75)' ) ) . toEqual ( {
145
+ alpha : 0.75 ,
146
+ hue : 209.99999999999997 ,
147
+ lightness : 0.4 ,
148
+ saturation : 0.09803921568627451 ,
149
+ } )
150
+ } )
151
+
152
+ it ( 'should parse a hsla 4 space-separated color representation with a float' , ( ) => {
153
+ expect ( parseToHsl ( 'hsla(210.99 10% 40% / 0.75)' ) ) . toEqual ( {
154
+ alpha : 0.75 ,
155
+ hue : 209.99999999999997 ,
156
+ lightness : 0.4 ,
157
+ saturation : 0.09803921568627451 ,
158
+ } )
159
+ expect ( parseToHsl ( 'hsla(210.99deg 10% 40% / 0.75)' ) ) . toEqual ( {
160
+ alpha : 0.75 ,
161
+ hue : 209.99999999999997 ,
162
+ lightness : 0.4 ,
163
+ saturation : 0.09803921568627451 ,
164
+ } )
87
165
} )
88
166
89
167
it ( 'should throw an error if an invalid color string is provided' , ( ) => {
0 commit comments