Skip to content

Commit

Permalink
add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
bradlc committed Mar 24, 2019
1 parent 1121eff commit be3be14
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions __tests__/resolveConfig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,66 @@ test('the theme function can use a default value if the key is missing', () => {
})
})

test('the theme function can resolve function values', () => {
const userConfig = {
theme: {
backgroundColor: theme => ({
orange: 'orange',
...theme('colors'),
}),
borderColor: theme => theme('backgroundColor'),
},
}

const defaultConfig = {
prefix: '-',
important: false,
separator: ':',
theme: {
colors: {
red: 'red',
green: 'green',
blue: 'blue',
},
},
variants: {
backgroundColor: ['responsive', 'hover', 'focus'],
borderColor: ['responsive', 'hover', 'focus'],
},
}

const result = resolveConfig([userConfig, defaultConfig])

expect(result).toEqual({
prefix: '-',
important: false,
separator: ':',
theme: {
colors: {
red: 'red',
green: 'green',
blue: 'blue',
},
backgroundColor: {
orange: 'orange',
red: 'red',
green: 'green',
blue: 'blue',
},
borderColor: {
orange: 'orange',
red: 'red',
green: 'green',
blue: 'blue',
},
},
variants: {
backgroundColor: ['responsive', 'hover', 'focus'],
borderColor: ['responsive', 'hover', 'focus'],
},
})
})

test('theme values in the extend section are lazily evaluated', () => {
const userConfig = {
theme: {
Expand Down

0 comments on commit be3be14

Please sign in to comment.