Skip to content

Commit 70787fc

Browse files
htunnicliffRobinMalfait
authored andcommitted
Add tests
1 parent ff9b06a commit 70787fc

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/withAlphaVariable.test.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ test('it ignores colors that already have an alpha channel', () => {
7676
).toEqual({
7777
'background-color': 'rgba(255, 255, 255, 0.5)',
7878
})
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+
})
7988
expect(
8089
withAlphaVariable({
8190
color: 'hsla(240, 100%, 50%, 1)',
@@ -94,6 +103,15 @@ test('it ignores colors that already have an alpha channel', () => {
94103
).toEqual({
95104
'background-color': 'hsla(240, 100%, 50%, 0.5)',
96105
})
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+
})
97115
})
98116

99117
test('it allows a closure to be passed', () => {
@@ -130,6 +148,16 @@ test('it transforms rgb and hsl to rgba and hsla', () => {
130148
'--tw-bg-opacity': '1',
131149
'background-color': 'rgba(50, 50, 50, var(--tw-bg-opacity))',
132150
})
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+
})
133161
expect(
134162
withAlphaVariable({
135163
color: 'hsl(50, 50%, 50%)',
@@ -140,4 +168,14 @@ test('it transforms rgb and hsl to rgba and hsla', () => {
140168
'--tw-bg-opacity': '1',
141169
'background-color': 'hsla(50, 50%, 50%, var(--tw-bg-opacity))',
142170
})
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+
})
143181
})

0 commit comments

Comments
 (0)