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) {
183183
184184 let newValue
185185
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+
186192 //check if values are nested objects
187193 if ( typeof originalValue === 'object' && typeof mixinValue === 'object' ) {
188194 //go recursive
Original file line number Diff line number Diff line change @@ -555,4 +555,10 @@ describe('themeable function', () => {
555555 const result = themeable ( themeA , themeB )
556556 expect ( result ) . toEqual ( expected )
557557 } )
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+ } )
558564} )
You can’t perform that action at this time.
0 commit comments