init
This commit is contained in:
commit
895b92a157
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
/node_modules/
|
||||
/yarn.lock
|
9
index.js
Normal file
9
index.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
module.exports = (variants) => {
|
||||
return function ({ addUtilities }) {
|
||||
addUtilities({
|
||||
'.test': {
|
||||
display: 'block'
|
||||
},
|
||||
}, variants)
|
||||
}
|
||||
}
|
24
package.json
Normal file
24
package.json
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "tailwindcss-plugin-jest-example",
|
||||
"version": "0.1.0",
|
||||
"description": "An example showing how to write tests for for Tailwind CSS plugins.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
},
|
||||
"keywords": ["tailwindcss", "jest"],
|
||||
"author": {
|
||||
"name": "Oliver Davies",
|
||||
"url" : "https://www.oliverdavies.uk"
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"jest": "^24.7.1",
|
||||
"jest-matcher-css": "^1.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.11",
|
||||
"postcss": "^7.0.14",
|
||||
"tailwindcss": "^1.0.0-beta.4"
|
||||
}
|
||||
}
|
41
test.js
Normal file
41
test.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
const _ = require('lodash')
|
||||
const cssMatcher = require('jest-matcher-css')
|
||||
const defaultConfig = require('tailwindcss/defaultConfig')
|
||||
const plugin = require('./index.js')
|
||||
const postcss = require('postcss')
|
||||
const tailwindcss = require('tailwindcss')
|
||||
|
||||
const disableCorePlugins = () => {
|
||||
return _.mapValues(defaultConfig.variants, plugin => {
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
const generatePluginCss = () => {
|
||||
return postcss(
|
||||
tailwindcss({
|
||||
corePlugins: disableCorePlugins(),
|
||||
plugins: [plugin()]
|
||||
})
|
||||
)
|
||||
.process('@tailwind utilities;', {
|
||||
from: undefined
|
||||
})
|
||||
.then(result => {
|
||||
return result.css
|
||||
})
|
||||
}
|
||||
|
||||
expect.extend({
|
||||
toMatchCss: cssMatcher
|
||||
})
|
||||
|
||||
test('it generates classes', () => {
|
||||
return generatePluginCss().then(css => {
|
||||
expect(css).toMatchCss(`
|
||||
.test {
|
||||
display: block;
|
||||
}
|
||||
`)
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue