Remove options key from config

This commit is contained in:
Adam Wathan 2019-01-18 09:27:49 -05:00
parent e8d16fcdb5
commit 326f35a72a
5 changed files with 26 additions and 50 deletions

View File

@ -203,9 +203,6 @@ test('you can apply utility classes without using the given prefix', () => {
const config = {
...defaultConfig,
prefix: 'tw-',
options: {
...defaultConfig.options,
},
}
return run(input, config, processPlugins(defaultPlugins(defaultConfig), config).utilities).then(
@ -230,9 +227,6 @@ test('you can apply utility classes without using the given prefix when using a
prefix: () => {
return 'tw-'
},
options: {
...defaultConfig.options,
},
}
return run(input, config, processPlugins(defaultPlugins(defaultConfig), config).utilities).then(

View File

@ -16,10 +16,6 @@ function config(overrides) {
xl: '1200px',
},
prefix: '',
options: {
important: false,
separator: ':',
},
})
}

View File

@ -1,10 +1,35 @@
import mergeConfigWithDefaults from '../src/util/mergeConfigWithDefaults'
test('user top-level keys override default top-level keys except modules', () => {
const userConfig = {
modules: {},
prefix: 'tw-',
important: true,
}
const defaultConfig = {
modules: {
flexbox: ['responsive'],
},
prefix: '-',
important: false,
}
const result = mergeConfigWithDefaults(userConfig, defaultConfig)
expect(result).toEqual({
modules: {
flexbox: ['responsive'],
},
prefix: 'tw-',
important: true,
})
})
test('missing top level keys are pulled from the default config', () => {
const userConfig = {
colors: { red: '#ff0000' },
modules: {},
options: {},
}
const defaultConfig = {
@ -13,7 +38,6 @@ test('missing top level keys are pulled from the default config', () => {
sm: '576px',
},
modules: {},
options: {},
}
const result = mergeConfigWithDefaults(userConfig, defaultConfig)
@ -24,14 +48,12 @@ test('missing top level keys are pulled from the default config', () => {
sm: '576px',
},
modules: {},
options: {},
})
})
test('user modules are merged with default modules', () => {
const userConfig = {
modules: { flexbox: false },
options: {},
}
const defaultConfig = {
@ -39,7 +61,6 @@ test('user modules are merged with default modules', () => {
flexbox: ['responsive'],
textAlign: ['responsive'],
},
options: {},
}
const result = mergeConfigWithDefaults(userConfig, defaultConfig)
@ -49,14 +70,12 @@ test('user modules are merged with default modules', () => {
flexbox: false,
textAlign: ['responsive'],
},
options: {},
})
})
test('setting modules to "all" creates all variants for all modules', () => {
const userConfig = {
modules: 'all',
options: {},
}
const defaultConfig = {
@ -65,7 +84,6 @@ test('setting modules to "all" creates all variants for all modules', () => {
textAlign: ['hover'],
textColors: ['focus'],
},
options: {},
}
const result = mergeConfigWithDefaults(userConfig, defaultConfig)
@ -76,14 +94,12 @@ test('setting modules to "all" creates all variants for all modules', () => {
textAlign: ['responsive', 'group-hover', 'hover', 'focus-within', 'focus', 'active'],
textColors: ['responsive', 'group-hover', 'hover', 'focus-within', 'focus', 'active'],
},
options: {},
})
})
test('setting modules to an array of variants applies those variants to all modules', () => {
const userConfig = {
modules: ['responsive', 'focus', 'hover', 'custom-variant'],
options: {},
}
const defaultConfig = {
@ -92,7 +108,6 @@ test('setting modules to an array of variants applies those variants to all modu
textAlign: ['hover'],
textColors: ['focus'],
},
options: {},
}
const result = mergeConfigWithDefaults(userConfig, defaultConfig)
@ -103,31 +118,5 @@ test('setting modules to an array of variants applies those variants to all modu
textAlign: ['responsive', 'focus', 'hover', 'custom-variant'],
textColors: ['responsive', 'focus', 'hover', 'custom-variant'],
},
options: {},
})
})
test('user options are merged with default options', () => {
const userConfig = {
modules: {},
options: { prefix: 'tw-' },
}
const defaultConfig = {
modules: {},
options: {
prefix: '-',
important: false,
},
}
const result = mergeConfigWithDefaults(userConfig, defaultConfig)
expect(result).toEqual({
modules: {},
options: {
prefix: 'tw-',
important: false,
},
})
})

View File

@ -974,7 +974,5 @@ module.exports = {
prefix: '',
important: false,
separator: ':',
options: {
},
}

View File

@ -22,6 +22,5 @@ function mergeModules(userModules, defaultModules) {
export default function(userConfig, defaultConfig) {
_.defaults(userConfig, defaultConfig)
userConfig.modules = mergeModules(userConfig.modules, defaultConfig.modules)
userConfig.options = _.defaults(userConfig.options, defaultConfig.options)
return userConfig
}