@@ -345,6 +345,27 @@ describe('MatRadio', () => {
345
345
expect ( radioInstances [ 2 ] . checked ) . toBeFalsy ( 'should not select the third button' ) ;
346
346
} ) ;
347
347
348
+ it ( `should update checked status if changed value to radio group's value` , ( ) => {
349
+ groupInstance . value = 'apple' ;
350
+ radioInstances [ 0 ] . value = 'apple' ;
351
+ fixture . detectChanges ( ) ;
352
+
353
+ expect ( groupInstance . selected ) . toBe (
354
+ radioInstances [ 0 ] , 'expect group selected to be first button' ) ;
355
+ expect ( radioInstances [ 0 ] . checked ) . toBeTruthy ( 'expect group select the first button' ) ;
356
+ expect ( radioInstances [ 1 ] . checked ) . toBeFalsy ( 'should not select the second button' ) ;
357
+ expect ( radioInstances [ 2 ] . checked ) . toBeFalsy ( 'should not select the third button' ) ;
358
+
359
+ radioInstances [ 0 ] . value = 'watermelon' ;
360
+ fixture . detectChanges ( ) ;
361
+
362
+ expect ( groupInstance . value ) . toBeFalsy ( ) ;
363
+ expect ( groupInstance . selected ) . toBeFalsy ( 'expect group selected to be null' ) ;
364
+ expect ( radioInstances [ 0 ] . checked ) . toBeFalsy ( 'should not select the first button' ) ;
365
+ expect ( radioInstances [ 1 ] . checked ) . toBeFalsy ( 'should not select the second button' ) ;
366
+ expect ( radioInstances [ 2 ] . checked ) . toBeFalsy ( 'should not select the third button' ) ;
367
+ } ) ;
368
+
348
369
it ( 'should apply class based on color attribute' , ( ) => {
349
370
expect ( radioNativeElements . every ( radioEl => radioEl . classList . contains ( 'mat-accent' ) ) )
350
371
. toBe ( true , 'Expected every radio element to use the accent color by default.' ) ;
0 commit comments