@@ -841,6 +841,21 @@ describe('MatButtonToggle without forms', () => {
841
841
expect ( fixture . componentInstance . toggles . toArray ( ) [ 1 ] . checked ) . toBe ( true ) ;
842
842
} ) ;
843
843
844
+ it ( 'should not throw on init when toggles are repeated and there is an initial value null' , ( ) => {
845
+ const fixture = TestBed . createComponent ( RepeatedButtonTogglesWithPreselectedValue ) ;
846
+ fixture . detectChanges ( ) ;
847
+
848
+ expect ( fixture . componentInstance . toggleGroup . value ) . toBe ( 'Two' ) ;
849
+ expect ( fixture . componentInstance . toggles . toArray ( ) [ 1 ] . checked ) . toBe ( true ) ;
850
+
851
+ fixture . componentInstance . possibleValues = [ null , 'Five' , 'Six' ] ;
852
+ fixture . componentInstance . value = null ;
853
+ fixture . detectChanges ( ) ;
854
+
855
+ expect ( fixture . componentInstance . toggleGroup . value ) . toBe ( null ) ;
856
+ expect ( fixture . componentInstance . toggles . toArray ( ) [ 0 ] . checked ) . toBe ( true ) ;
857
+ } ) ;
858
+
844
859
it ( 'should not throw on init when toggles are repeated and there is an initial value' , ( ) => {
845
860
const fixture = TestBed . createComponent ( ButtonToggleWithStaticName ) ;
846
861
fixture . detectChanges ( ) ;
@@ -1064,8 +1079,8 @@ class RepeatedButtonTogglesWithPreselectedValue {
1064
1079
@ViewChild ( MatButtonToggleGroup ) toggleGroup : MatButtonToggleGroup ;
1065
1080
@ViewChildren ( MatButtonToggle ) toggles : QueryList < MatButtonToggle > ;
1066
1081
1067
- possibleValues = [ 'One' , 'Two' , 'Three' ] ;
1068
- value = 'Two' ;
1082
+ possibleValues : ( string | null ) [ ] = [ 'One' , 'Two' , 'Three' ] ;
1083
+ value : string | null = 'Two' ;
1069
1084
}
1070
1085
1071
1086
@Component ( {
0 commit comments