@@ -874,7 +874,7 @@ describe('MatCheckbox', () => {
874
874
let inputElement : HTMLInputElement ;
875
875
let ngModel : NgModel ;
876
876
877
- beforeEach ( ( ) => {
877
+ beforeEach ( fakeAsync ( ( ) => {
878
878
fixture = createComponent ( CheckboxWithNgModel ) ;
879
879
880
880
fixture . componentInstance . isRequired = false ;
@@ -885,7 +885,7 @@ describe('MatCheckbox', () => {
885
885
checkboxInstance = checkboxDebugElement . componentInstance ;
886
886
inputElement = < HTMLInputElement > checkboxNativeElement . querySelector ( 'input' ) ;
887
887
ngModel = checkboxDebugElement . injector . get < NgModel > ( NgModel ) ;
888
- } ) ;
888
+ } ) ) ;
889
889
890
890
it ( 'should be pristine, untouched, and valid initially' , ( ) => {
891
891
expect ( ngModel . valid ) . toBe ( true ) ;
@@ -984,6 +984,18 @@ describe('MatCheckbox', () => {
984
984
expect ( checkboxInstance . checked ) . toBe ( false ) ;
985
985
expect ( ngModel . valid ) . toBe ( false ) ;
986
986
} ) ;
987
+
988
+ it ( 'should updated the ngModel value when using the `toggle` method' , fakeAsync ( ( ) => {
989
+ const checkbox = fixture . debugElement . query ( By . directive ( MatCheckbox ) ) . componentInstance ;
990
+
991
+ expect ( fixture . componentInstance . isGood ) . toBe ( false ) ;
992
+
993
+ checkbox . toggle ( ) ;
994
+ fixture . detectChanges ( ) ;
995
+
996
+ expect ( fixture . componentInstance . isGood ) . toBe ( true ) ;
997
+ } ) ) ;
998
+
987
999
} ) ;
988
1000
989
1001
describe ( 'with name attribute' , ( ) => {
0 commit comments