@@ -76,6 +76,15 @@ test('it ignores colors that already have an alpha channel', () => {
76
76
) . toEqual ( {
77
77
'background-color' : 'rgba(255, 255, 255, 0.5)' ,
78
78
} )
79
+ expect (
80
+ withAlphaVariable ( {
81
+ color : 'rgba(255 255 255 / 0.5)' ,
82
+ property : 'background-color' ,
83
+ variable : '--tw-bg-opacity' ,
84
+ } )
85
+ ) . toEqual ( {
86
+ 'background-color' : 'rgba(255 255 255 / 0.5)' ,
87
+ } )
79
88
expect (
80
89
withAlphaVariable ( {
81
90
color : 'hsla(240, 100%, 50%, 1)' ,
@@ -94,6 +103,15 @@ test('it ignores colors that already have an alpha channel', () => {
94
103
) . toEqual ( {
95
104
'background-color' : 'hsla(240, 100%, 50%, 0.5)' ,
96
105
} )
106
+ expect (
107
+ withAlphaVariable ( {
108
+ color : 'hsl(240 100% 50% / 0.5)' ,
109
+ property : 'background-color' ,
110
+ variable : '--tw-bg-opacity' ,
111
+ } )
112
+ ) . toEqual ( {
113
+ 'background-color' : 'hsl(240 100% 50% / 0.5)' ,
114
+ } )
97
115
} )
98
116
99
117
test ( 'it allows a closure to be passed' , ( ) => {
@@ -130,6 +148,16 @@ test('it transforms rgb and hsl to rgba and hsla', () => {
130
148
'--tw-bg-opacity' : '1' ,
131
149
'background-color' : 'rgba(50, 50, 50, var(--tw-bg-opacity))' ,
132
150
} )
151
+ expect (
152
+ withAlphaVariable ( {
153
+ color : 'rgb(50 50 50)' ,
154
+ property : 'background-color' ,
155
+ variable : '--tw-bg-opacity' ,
156
+ } )
157
+ ) . toEqual ( {
158
+ '--tw-bg-opacity' : '1' ,
159
+ 'background-color' : 'rgba(50, 50, 50, var(--tw-bg-opacity))' ,
160
+ } )
133
161
expect (
134
162
withAlphaVariable ( {
135
163
color : 'hsl(50, 50%, 50%)' ,
@@ -140,4 +168,14 @@ test('it transforms rgb and hsl to rgba and hsla', () => {
140
168
'--tw-bg-opacity' : '1' ,
141
169
'background-color' : 'hsla(50, 50%, 50%, var(--tw-bg-opacity))' ,
142
170
} )
171
+ expect (
172
+ withAlphaVariable ( {
173
+ color : 'hsl(50 50% 50%)' ,
174
+ property : 'background-color' ,
175
+ variable : '--tw-bg-opacity' ,
176
+ } )
177
+ ) . toEqual ( {
178
+ '--tw-bg-opacity' : '1' ,
179
+ 'background-color' : 'hsla(50, 50%, 50%, var(--tw-bg-opacity))' ,
180
+ } )
143
181
} )
0 commit comments