mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Add helper for testing utility plugins
This commit is contained in:
parent
915d9c60e5
commit
921e2ff202
29
__tests__/plugins/util/invokePlugin.js
Normal file
29
__tests__/plugins/util/invokePlugin.js
Normal file
@ -0,0 +1,29 @@
|
||||
import _ from 'lodash'
|
||||
import escapeClassName from '../../../src/util/escapeClassName'
|
||||
|
||||
export default function(plugin, config) {
|
||||
const addedUtilities = []
|
||||
|
||||
const getConfigValue = (path, defaultValue) => _.get(config, path, defaultValue)
|
||||
const pluginApi = {
|
||||
config: getConfigValue,
|
||||
e: escapeClassName,
|
||||
theme: (path, defaultValue) => getConfigValue(`theme.${path}`, defaultValue),
|
||||
variants: (path, defaultValue) => {
|
||||
if (_.isArray(config.variants)) {
|
||||
return config.variants
|
||||
}
|
||||
|
||||
return getConfigValue(`variants.${path}`, defaultValue)
|
||||
},
|
||||
addUtilities(utilities, variants) {
|
||||
addedUtilities.push([utilities, variants])
|
||||
},
|
||||
}
|
||||
|
||||
plugin(pluginApi)
|
||||
|
||||
return {
|
||||
utilities: addedUtilities,
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user