lundi 20 mai 2019

How do i test when an tag is clicked on, whether it opens up a new tab/window

I am trying to test when triggering a click event whether a new tab/window gets opened.

this is what i tried so far

 it('should open a new tab', ()=>{
      spyOn(window, 'open');
      view.$('.redeem-online')[0].click();
      expect(window.open).toHaveBeenCalled();
    });

problem I am facing:

1) when triggering the click event it opens a new tab during the test, how do i prevent the tab from opening during the test when this line of code is run

view.$('.redeem-online')[0].click();

Aucun commentaire:

Enregistrer un commentaire