diff --git a/__tests__/mergeConfigWithDefaults.test.js b/__tests__/mergeConfigWithDefaults.test.js index c6474794c..5b787bf1b 100644 --- a/__tests__/mergeConfigWithDefaults.test.js +++ b/__tests__/mergeConfigWithDefaults.test.js @@ -80,6 +80,33 @@ test('setting modules to "all" creates all variants for all modules', () => { }) }) +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 = { + modules: { + flexbox: ['responsive'], + textAlign: ['hover'], + textColors: ['focus'], + }, + options: {}, + } + + const result = mergeConfigWithDefaults(userConfig, defaultConfig) + + expect(result).toEqual({ + modules: { + flexbox: ['responsive', 'focus', 'hover', 'custom-variant'], + textAlign: ['responsive', 'focus', 'hover', 'custom-variant'], + textColors: ['responsive', 'focus', 'hover', 'custom-variant'], + }, + options: {}, + }) +}) + test('user options are merged with default options', () => { const userConfig = { modules: {}, diff --git a/src/util/mergeConfigWithDefaults.js b/src/util/mergeConfigWithDefaults.js index 8e5af64f4..44c996538 100644 --- a/src/util/mergeConfigWithDefaults.js +++ b/src/util/mergeConfigWithDefaults.js @@ -1,6 +1,10 @@ import _ from 'lodash' function mergeModules(userModules, defaultModules) { + if (_.isArray(userModules)) { + return _.mapValues(defaultModules, () => userModules) + } + if (userModules === 'all') { return _.mapValues(defaultModules, () => [ 'responsive',