@@ -356,8 +356,40 @@ describe('Modifiers', () => {
356
356
} ) ;
357
357
358
358
it ( 'should prioritize forced theme props over user props' , ( ) => {
359
- ThemeManager . setComponentForcedTheme ( 'SampleComponent' , props => ( { foo : 'forced' } ) ) ;
360
- expect ( uut . getThemeProps . call ( SampleComponent , { foo : 'user-value' , other : 'other' } ) ) . toEqual ( { foo : 'forced' , other : 'other' } ) ;
359
+ ThemeManager . setComponentForcedTheme ( 'SampleComponent' , ( props ) => ( { foo : 'forced' } ) ) ;
360
+ expect ( uut . getThemeProps . call ( SampleComponent , { foo : 'user-value' , other : 'other' } ) ) . toEqual ( {
361
+ foo : 'forced' ,
362
+ other : 'other'
363
+ } ) ;
364
+ } ) ;
365
+ } ) ;
366
+
367
+ describe ( 'generateModifiersStyle' , ( ) => {
368
+ it ( 'should generate modifiers object out of props' , ( ) => {
369
+ const modifiers = uut . generateModifiersStyle ( undefined , {
370
+ 'bg-red40' : true ,
371
+ 'padding-20' : true ,
372
+ 'margin-20' : true ,
373
+ flex : true ,
374
+ bottom : true ,
375
+ br100 : true
376
+ } ) ;
377
+ expect ( modifiers . backgroundColor ) . toBe ( Colors . red40 ) ;
378
+ expect ( modifiers . paddings ) . toEqual ( { padding : 20 } ) ;
379
+ expect ( modifiers . margins ) . toEqual ( { margin : 20 } ) ;
380
+ expect ( modifiers . flexStyle ) . toEqual ( { flex : 1 } ) ;
381
+ expect ( modifiers . alignments ) . toEqual ( { justifyContent : 'flex-end' } ) ;
382
+ expect ( modifiers . borderRadius ) . toEqual ( BorderRadiuses . br100 ) ;
383
+ } ) ;
384
+
385
+ it ( 'should not include empty modifiers values' , ( ) => {
386
+ const modifiers = uut . generateModifiersStyle ( undefined , { 'bg-red40' : true } ) ;
387
+ expect ( modifiers . backgroundColor ) . toBe ( Colors . red40 ) ;
388
+ expect ( modifiers . paddings ) . toBeUndefined ( ) ;
389
+ expect ( modifiers . margins ) . toBeUndefined ( ) ;
390
+ expect ( modifiers . flexStyle ) . toBeUndefined ( ) ;
391
+ expect ( modifiers . alignments ) . toBeUndefined ( ) ;
392
+ expect ( modifiers . borderRadius ) . toBeUndefined ( ) ;
361
393
} ) ;
362
394
} ) ;
363
395
} ) ;
0 commit comments