test(gradientColorStops): ensure opacity variables are generated

This commit is contained in:
Enzo Innocenzi 2020-08-18 23:26:29 +02:00
parent 486772a82d
commit f6fc9630d5
No known key found for this signature in database
GPG key ID: 142E4908E855E2B1

View file

@ -0,0 +1,38 @@
import postcss from 'postcss'
import tailwind from '../../src/index'
test('opacity variables are given to colors defined as closures', () => {
return postcss([
tailwind({
theme: {
colors: {
primary: ({ opacityVariable }) => `rgba(31,31,31,var(${opacityVariable},1))`,
},
},
variants: {
gradientColorStops: [],
},
corePlugins: ['gradientColorStops'],
}),
])
.process('@tailwind utilities', { from: undefined })
.then(result => {
const expected = `
.from-primary {
--gradient-from-color: rgba(31,31,31,var(--gradient-from-opacity,1));
--gradient-color-stops: var(--gradient-from-color), var(--gradient-to-color, rgba(255, 255, 255, 0))
}
.via-primary {
--gradient-via-color: rgba(31,31,31,var(--gradient-via-opacity,1));
--gradient-color-stops: var(--gradient-from-color), var(--gradient-via-color), var(--gradient-to-color, rgba(255, 255, 255, 0))
}
.to-primary {
--gradient-to-color: rgba(31,31,31,var(--gradient-to-opacity,1))
}
`
expect(result.css).toMatchCss(expected)
})
})