Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49083

Unit tests for alert controller in ionic

$
0
0

I am learning to write unit tests in ionic and am unable to write a test for AlertController. Below attached is the code

async BackupSQL() {
    const alert = await this.alertController.create({
      cssClass: 'my-custom-class',
      header: 'BACKUP',
      message: 'Are you sure want to backup data?',
      buttons: [
        {
          text: 'Cancel',
          role: 'cancel',
          cssClass: 'secondary',
          handler: (blah) => {
          }
        }, {
          text: 'OK',
          handler: (data) => {
            this.exportToSQL();
          }
        }
      ]
    });
    await alert.present();
  }

please help me to find solutions for handler event in unit test case coverage. Would really appreciate it if someone could help me write test case to cover the alert button actions and present. Thanks in advance

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>