1
+ const _ = require ( 'lodash' )
2
+
1
3
const plugin = require ( './index.js' )
2
4
const postcss = require ( 'postcss' )
3
5
const tailwindcss = require ( 'tailwindcss' )
@@ -10,7 +12,7 @@ const generatePluginCss = (testConfig = {}, pluginOptions = {}) => {
10
12
plugins : [ plugin ( pluginOptions ) ] ,
11
13
}
12
14
const postcssPlugins = [
13
- tailwindcss ( { ... sandboxConfig , ... testConfig } ) ,
15
+ tailwindcss ( _ . merge ( sandboxConfig , testConfig ) ) ,
14
16
]
15
17
16
18
return postcss ( postcssPlugins )
@@ -20,7 +22,7 @@ const generatePluginCss = (testConfig = {}, pluginOptions = {}) => {
20
22
21
23
expect . extend ( { toMatchCss : require ( 'jest-matcher-css' ) } )
22
24
23
- test ( 'the plugin generates some utilities and responsive variants by default ' , ( ) => {
25
+ test ( 'generates default utilities and responsive variants' , ( ) => {
24
26
const testConfig = { }
25
27
const expectedCss = `
26
28
.bg-clip-border { background-clip: border-box }
@@ -76,3 +78,40 @@ test('variants can be customized', () => {
76
78
77
79
return generatePluginCss ( testConfig ) . then ( css => expect ( css ) . toMatchCss ( expectedCss ) )
78
80
} )
81
+
82
+ test ( 'utilities can be customized' , ( ) => {
83
+ const testConfig = {
84
+ theme : {
85
+ backgroundImage : {
86
+ tailwindcss : "url('https://avatars0.githubusercontent.com/u/30317862')" ,
87
+ } ,
88
+ } ,
89
+ }
90
+ const expectedCss = `
91
+ .bg-image-tailwindcss { background-image: url('https://avatars0.githubusercontent.com/u/30317862') }
92
+
93
+ .bg-clip-border { background-clip: border-box }
94
+ .bg-clip-padding { background-clip: padding-box }
95
+ .bg-clip-content { background-clip: content-box }
96
+ .bg-clip-text { background-clip: text }
97
+
98
+ .bg-origin-border { background-origin: border-box }
99
+ .bg-origin-padding { background-origin: padding-box }
100
+ .bg-origin-content { background-origin: content-box }
101
+
102
+ @media (min-width: 640px) {
103
+ .sm\\:bg-image-tailwindcss { background-image: url('https://avatars0.githubusercontent.com/u/30317862') }
104
+
105
+ .sm\\:bg-clip-border { background-clip: border-box }
106
+ .sm\\:bg-clip-padding { background-clip: padding-box }
107
+ .sm\\:bg-clip-content { background-clip: content-box }
108
+ .sm\\:bg-clip-text { background-clip: text }
109
+
110
+ .sm\\:bg-origin-border { background-origin: border-box }
111
+ .sm\\:bg-origin-padding { background-origin: padding-box }
112
+ .sm\\:bg-origin-content { background-origin: content-box }
113
+ }
114
+ `
115
+
116
+ return generatePluginCss ( testConfig ) . then ( css => expect ( css ) . toMatchCss ( expectedCss ) )
117
+ } )
0 commit comments