@@ -560,6 +560,52 @@ describe('GridColumn factory', function () {
560
560
expect ( updateCol ( colDef . width ) ) . toThrow ( ) ;
561
561
} ) ;
562
562
563
+ it ( 'should set the value of minWidth to 30 when colDef.minWidth is undefined' , invalidMinOrMaxWidthDef ( undefined , 'minWidth' ) ) ;
564
+ it ( 'should set the value of minWidth to 30 when colDef.minWidth is null' , invalidMinOrMaxWidthDef ( null , 'minWidth' ) ) ;
565
+ it ( 'should set the value of minWidth to 30 when colDef.minWidth is an object' , invalidMinOrMaxWidthDef ( { } , 'minWidth' ) ) ;
566
+
567
+ it ( 'should set the value of minWidth to the parsed integer colDef.minWidth when it is a string' , function ( ) {
568
+ colDef . minWidth = '90' ;
569
+ col . updateColumnDef ( colDef ) ;
570
+ expect ( col . minWidth ) . toBe ( 90 ) ;
571
+ } ) ;
572
+
573
+ it ( 'should set the value of minWidth to colDef.minWidth when it is a number' , function ( ) {
574
+ colDef . minWidth = 90 ;
575
+ col . updateColumnDef ( colDef ) ;
576
+ expect ( col . minWidth ) . toBe ( 90 ) ;
577
+ } ) ;
578
+
579
+ it ( 'should throw when colDef.minWidth is an invalid string' , function ( ) {
580
+ colDef . minWidth = 'e1%' ;
581
+ expect ( updateCol ( col , colDef ) ) . toThrow ( ) ;
582
+ colDef . minWidth = '#FFF' ;
583
+ expect ( updateCol ( col , colDef ) ) . toThrow ( ) ;
584
+ } ) ;
585
+
586
+ it ( 'should set the value of maxWidth to 9000 when colDef.maxWidth is undefined' , invalidMinOrMaxWidthDef ( undefined , 'maxWidth' ) ) ;
587
+ it ( 'should set the value of maxWidth to 9000 when colDef.maxWidth is null' , invalidMinOrMaxWidthDef ( null , 'maxWidth' ) ) ;
588
+ it ( 'should set the value of maxWidth to 9000 when colDef.maxWidth is an object' , invalidMinOrMaxWidthDef ( { } , 'maxWidth' ) ) ;
589
+
590
+ it ( 'should set the value of maxWidth to the parsed integer colDef.maxWidth when it is a string' , function ( ) {
591
+ colDef . maxWidth = '200' ;
592
+ col . updateColumnDef ( colDef ) ;
593
+ expect ( col . maxWidth ) . toBe ( 200 ) ;
594
+ } ) ;
595
+
596
+ it ( 'should set the value of maxWidth to colDef.maxWidth when it is a number' , function ( ) {
597
+ colDef . maxWidth = 200 ;
598
+ col . updateColumnDef ( colDef ) ;
599
+ expect ( col . maxWidth ) . toBe ( 200 ) ;
600
+ } ) ;
601
+
602
+ it ( 'should throw when colDef.maxWidth is an invalid string' , function ( ) {
603
+ colDef . maxWidth = 'e1%' ;
604
+ expect ( updateCol ( col , colDef ) ) . toThrow ( ) ;
605
+ colDef . maxWidth = '#FFF' ;
606
+ expect ( updateCol ( col , colDef ) ) . toThrow ( ) ;
607
+ } ) ;
608
+
563
609
function widthEqualsColDefWidth ( expected ) {
564
610
return function ( ) {
565
611
colDef . width = expected ;
@@ -581,5 +627,13 @@ describe('GridColumn factory', function () {
581
627
col . updateColumnDef ( colDef ) ;
582
628
} ;
583
629
}
630
+
631
+ function invalidMinOrMaxWidthDef ( width , minOrMax ) {
632
+ return function ( ) {
633
+ colDef [ minOrMax ] = width ;
634
+ col . updateColumnDef ( colDef ) ;
635
+ expect ( col [ minOrMax ] ) . toBe ( minOrMax === 'minWidth' ? 30 : 9000 ) ;
636
+ } ;
637
+ }
584
638
} ) ;
585
639
} ) ;
0 commit comments