title: Angular 6: How to write jasmine test spec for a mat-dialog
body: <p>I trying to write a test spec for mat-dialog, but i could not be success, the problem is that it is called by a function. How to do that? Thanks for your help.
  Here is my code</p>
  
  <pre class="lang-js prettyprint-override"><code>closeDialogCancelButton() {
      if (this.editFormData.dirty) {
        let dialogRef = this.dialogCancel.open(DialogCancel,
          {
            width: '250px',
            disableClose: true,
            data:
            {
              id: '1'
            }
          });
        dialogRef.afterClosed().subscribe(result =&gt; {
          if (result)
            this.dialog.close();
        });
      } else
        this.dialog.close();
    }
  </code></pre>