mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Test that setting a plugin to false in corePlugins disables it
This commit is contained in:
parent
d165661da4
commit
ed20e59ba1
35
__tests__/configurePlugins.test.js
Normal file
35
__tests__/configurePlugins.test.js
Normal file
@ -0,0 +1,35 @@
|
||||
import configurePlugins from '../src/util/configurePlugins'
|
||||
|
||||
test('setting a plugin to false removes it', () => {
|
||||
const plugins = {
|
||||
fontSize: (options) => {
|
||||
return {
|
||||
plugin: 'fontSize',
|
||||
options,
|
||||
}
|
||||
},
|
||||
display: (options) => {
|
||||
return {
|
||||
plugin: 'display',
|
||||
options,
|
||||
}
|
||||
},
|
||||
backgroundPosition: (options) => {
|
||||
return {
|
||||
plugin: 'backgroundPosition',
|
||||
options,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
const configuredPlugins = configurePlugins(plugins, {
|
||||
fontSize: {},
|
||||
display: false,
|
||||
backgroundPosition: {},
|
||||
})
|
||||
|
||||
expect(configuredPlugins).toEqual([
|
||||
{ plugin: 'fontSize', options: {} },
|
||||
{ plugin: 'backgroundPosition', options: {} },
|
||||
])
|
||||
})
|
||||
7
src/util/configurePlugins.js
Normal file
7
src/util/configurePlugins.js
Normal file
@ -0,0 +1,7 @@
|
||||
export default function(plugins, pluginConfig) {
|
||||
return Object.keys(plugins).filter(pluginName => {
|
||||
return pluginConfig[pluginName] !== false
|
||||
}).map(pluginName => {
|
||||
return plugins[pluginName](pluginConfig[pluginName])
|
||||
})
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user