-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
46 lines (41 loc) · 992 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const merge = require('lodash/merge');
const cssMatcher = require('jest-matcher-css');
const postcss = require('postcss');
const tailwindcss = require('tailwindcss');
const customPlugin = require('./index.js');
expect.extend({
toMatchCss: cssMatcher,
});
function generatePluginCss(overrides) {
const config = {
theme: {
fontWeight: {
bold: 700,
},
},
variants: {
fontWeight: ['retina'],
},
corePlugins: ['fontWeight'],
plugins: [customPlugin],
};
return postcss(tailwindcss(merge(config, overrides)))
.process('@tailwind utilities', {
from: undefined,
})
.then(({ css }) => css);
}
test('utility classes can be generated', () => {
return generatePluginCss().then(css => {
expect(css).toMatchCss(`
.font-bold {
font-weight: 700;
}
@media (-webkit-min-device-pixel-ratio: 2),(min-resolution: 192dpi) {
.retina\\:font-bold {
font-weight: 700;
}
}
`);
});
});