Skip to content

Commit be3be14

Browse files
committed
add failing test
1 parent 1121eff commit be3be14

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

__tests__/resolveConfig.test.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,66 @@ test('the theme function can use a default value if the key is missing', () => {
758758
})
759759
})
760760

761+
test('the theme function can resolve function values', () => {
762+
const userConfig = {
763+
theme: {
764+
backgroundColor: theme => ({
765+
orange: 'orange',
766+
...theme('colors'),
767+
}),
768+
borderColor: theme => theme('backgroundColor'),
769+
},
770+
}
771+
772+
const defaultConfig = {
773+
prefix: '-',
774+
important: false,
775+
separator: ':',
776+
theme: {
777+
colors: {
778+
red: 'red',
779+
green: 'green',
780+
blue: 'blue',
781+
},
782+
},
783+
variants: {
784+
backgroundColor: ['responsive', 'hover', 'focus'],
785+
borderColor: ['responsive', 'hover', 'focus'],
786+
},
787+
}
788+
789+
const result = resolveConfig([userConfig, defaultConfig])
790+
791+
expect(result).toEqual({
792+
prefix: '-',
793+
important: false,
794+
separator: ':',
795+
theme: {
796+
colors: {
797+
red: 'red',
798+
green: 'green',
799+
blue: 'blue',
800+
},
801+
backgroundColor: {
802+
orange: 'orange',
803+
red: 'red',
804+
green: 'green',
805+
blue: 'blue',
806+
},
807+
borderColor: {
808+
orange: 'orange',
809+
red: 'red',
810+
green: 'green',
811+
blue: 'blue',
812+
},
813+
},
814+
variants: {
815+
backgroundColor: ['responsive', 'hover', 'focus'],
816+
borderColor: ['responsive', 'hover', 'focus'],
817+
},
818+
})
819+
})
820+
761821
test('theme values in the extend section are lazily evaluated', () => {
762822
const userConfig = {
763823
theme: {

0 commit comments

Comments
 (0)