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