title: dialogRef.afterClosed is not a function
body: <p>Hi im doing unit testing and trying to get coverage for my subscription. However it keeps failing with the error <strong>dialogRef.afterClosed is not a function</strong></p>
  
  <p>Im not sure at what or how I can spy on the afterClosed() function, but thats the only part I cant seem to cover. 
      ...</p>
  
  <pre><code>import { MatDialog } from '@angular/material/dialog';
  ....
  constructor( private dialog: MatDialog) { }
  
  showLogin(): void {
  
    const dialogRef = this.dialog.open(LoginDialogComponent, {
      width: '400px',
      height: 'auto',
      data: this.loginContext
    });
  
    dialogRef.afterClosed().subscribe(result =&gt; {
      if (this.loginContext.loggedIn) {
        this.showApply();
      }
    });
  }
  </code></pre>
  
  <p>this is the <strong>LoginDialogComponent</strong></p>
  
  <pre><code> ....
  
   @Component({
     selector: 'app-login-dialog',
     templateUrl: './login-dialog.component.html',
     styleUrls: ['./login-dialog.component.scss']
   })
   export class LoginDialogComponent implements OnInit {
  
     constructor(
       private authService: AuthService,
       private alertService: AlertService,
       public dialogRef: MatDialogRef&lt;LoginState&gt;,
       @Inject(MAT_DIALOG_DATA) public data: LoginState) { }
  
     ngOnInit() {
       this.data.loggedIn = false;
     }
  
     login(loginEvent: LoginEvent): void {
  
  
       this.authService.login(loginData).then(
         resp =&gt; {
           this.data.loggedIn = true; // feedback
           this.dialogRef.close();
         },
         err =&gt; {
           this.alertService.showAlert(err);
         }
       );
     }
  
   }
  </code></pre>