如何在茉莉花中单击“确定”以发出警报

时间:2019-04-24 12:40:16

标签: angular unit-testing jasmine

我正在为angular应用程序运行单元测试,当我触发按钮单击时,我得到一个警告框。如何单击,然后我要测试一些值。如何在Jasmine中实现这一目标?

InputBox.text="589789";
let spyOnalert=spyOn(window, "alert");//trying to spyon alert but fails
let InputButtons=fixture.debugElement.queryAll(By.css('.crendentialsPINButton'));
InputButtons[0].triggerEventHandler('click',null);//fires alert
fixture.detectChanges();

 //expect alert to be called
  expect(spyOnalert).toHaveBeenCalled();

//expect input box text to be changed
 expect(component.InputBoxValue).toBeEqual("589789"); //this also fails,only after clicking ok in the alert box this will change

0 个答案:

没有答案