如何在ionic 4中编写模态或警报弹出窗口的单元测试

时间:2019-09-03 13:15:02

标签: unit-testing angular7 ionic4

我想介绍离子4中警报控制器弹出窗口和回调处理程序的单元测试吗?

it('should open popup', () => {
  component.showAlertPopup();
  const popupElem = fixture.debugElement.queryAll(By.css('alert-inner-button'));
  console.log('popup element', popupElem);
});
async showAlertPopup() {
  const alertOpts: AlertOptions = {
    message: 'applied successfully',
    button: [{
      text: 'YES',
      handler: () => {
        this.router.navigateByUrl('app/home');
      }
    }]
  };
  const alert = await this.alertCtrl.create(alertOpts);
  console.log('alert', alert);
  alert.present();
}

我期望popup元素,但未定义。

0 个答案:

没有答案