Add tests

This commit is contained in:
Hunter Tunnicliff 2021-08-04 20:44:26 -07:00 • committed by Robin Malfait
parent ff9b06a95b
commit 70787fc088
No known key found for this signature in database
GPG key ID: 92F53D68B9041AFE

View file

@ -76,6 +76,15 @@ test('it ignores colors that already have an alpha channel', () => {
).toEqual({
'background-color': 'rgba(255, 255, 255, 0.5)',
})
expect(
withAlphaVariable({
color: 'rgba(255 255 255 / 0.5)',
property: 'background-color',
variable: '--tw-bg-opacity',
})
).toEqual({
'background-color': 'rgba(255 255 255 / 0.5)',
})
expect(
withAlphaVariable({
color: 'hsla(240, 100%, 50%, 1)',
@ -94,6 +103,15 @@ test('it ignores colors that already have an alpha channel', () => {
).toEqual({
'background-color': 'hsla(240, 100%, 50%, 0.5)',
})
expect(
withAlphaVariable({
color: 'hsl(240 100% 50% / 0.5)',
property: 'background-color',
variable: '--tw-bg-opacity',
})
).toEqual({
'background-color': 'hsl(240 100% 50% / 0.5)',
})
})
test('it allows a closure to be passed', () => {
@ -130,6 +148,16 @@ test('it transforms rgb and hsl to rgba and hsla', () => {
'--tw-bg-opacity': '1',
'background-color': 'rgba(50, 50, 50, var(--tw-bg-opacity))',
})
expect(
withAlphaVariable({
color: 'rgb(50 50 50)',
property: 'background-color',
variable: '--tw-bg-opacity',
})
).toEqual({
'--tw-bg-opacity': '1',
'background-color': 'rgba(50, 50, 50, var(--tw-bg-opacity))',
})
expect(
withAlphaVariable({
color: 'hsl(50, 50%, 50%)',
@ -140,4 +168,14 @@ test('it transforms rgb and hsl to rgba and hsla', () => {
'--tw-bg-opacity': '1',
'background-color': 'hsla(50, 50%, 50%, var(--tw-bg-opacity))',
})
expect(
withAlphaVariable({
color: 'hsl(50 50% 50%)',
property: 'background-color',
variable: '--tw-bg-opacity',
})
).toEqual({
'--tw-bg-opacity': '1',
'background-color': 'hsla(50, 50%, 50%, var(--tw-bg-opacity))',
})
})