File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -183,6 +183,12 @@ export function themeable(original = {}, mixin) {
183
183
184
184
let newValue
185
185
186
+ //when you are mixing an string with a object it should fail
187
+ invariant ( ! ( typeof originalValue === 'string' && typeof mixinValue === 'object' ) ,
188
+ `You are merging a string "${ originalValue } " with an Object,` +
189
+ 'Make sure you are passing the proper theme descriptors.'
190
+ )
191
+
186
192
//check if values are nested objects
187
193
if ( typeof originalValue === 'object' && typeof mixinValue === 'object' ) {
188
194
//go recursive
Original file line number Diff line number Diff line change @@ -555,4 +555,10 @@ describe('themeable function', () => {
555
555
const result = themeable ( themeA , themeB )
556
556
expect ( result ) . toEqual ( expected )
557
557
} )
558
+
559
+ it ( 'throws an exception when its called mixing a string with an object' , ( ) => {
560
+ expect ( ( ) => {
561
+ themeable ( 'fail' , { test : { foo : 'baz' } } )
562
+ } ) . toThrow ( / s u r e y o u a r e p a s s i n g t h e p r o p e r t h e m e d e s c r i p t o r s / )
563
+ } )
558
564
} )
You can’t perform that action at this time.
0 commit comments