title: Jasmine unit testing, how do I trigger the click event of ngx-modal-dialog
body: <p>I am working on an angular application and i am Unit testing the application using Jasmine.</p>
  
  <p>The application uses <code>ngx-modal-dialog</code>(<a href="https://www.npmjs.com/package/ngx-modal-dialog" rel="nofollow noreferrer">enter link description here</a>) plugin for Pop-up Dialog Box such as a a confirmation box as a dynamic component.</p>
  
  <p><a href="https://i.stack.imgur.com/PCc4z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PCc4z.png" alt="enter image description here"></a></p>
  
  <p>What i want is to trigger the click event for the confirm or cancel, whatever the user chooses.</p>
  
  <p>The code for the Pop-up Dialog box is as below:</p>
  
  <pre><code>export class SomeComponent {
  
  constructor(private modalService: ModalDialogService) {}
  cancleEditConfirmDialog() {
     this.modalService.openDialog(this.viewRef, {
     title: 'Discard Changes ',
     childComponent: SimpleModalComponent,
     data: {
       text: 'Changes will not be saved. Do you want to proceed?'
     },
     settings: {
       closeButtonClass: 'close theme-icon-close'
     },
     actionButtons: [
       {
         text: 'Discard',
         buttonClass: 'btn btn-success',
         onAction: () =&gt; new Promise((resolve: any) =&gt; {
           // invoke delete
           // do something such as discard changes
           resolve()
         })
       },
       {
         text: 'Cancel',
         buttonClass: 'btn btn-danger',
         onAction: () =&gt; new Promise((resolve: any) =&gt; {
           // cancel and close popup
           setTimeout(() =&gt; {
             resolve();
           }, 20);
         })
       }
     ]
   });
  }
  }
  </code></pre>
  
  <blockquote>
    <p>how do i trigger the <code>onAction: =&gt; ()</code> in the click event for discard button
    and for cancel button.</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/e46xC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e46xC.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/UJQSS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UJQSS.png" alt="enter image description here"></a></p>