vendredi 1 mars 2019

How can I test that a NgBootstrap Tooltip was opened?

I'm using ngBoostrap, Angular 7 and Karma 4.

I want to test if a Tooltip is opened when hovering over a div (and later if it contains the correct data).

At the momement I'm trying like this:

  it('displays data in tooltip', () => {
    const div = fixture.debugElement.nativeElement.querySelector('div');

    div.dispatchEvent(new MouseEvent('mouseover'), {
      view: window,
      bubbles: true,
      cancelable: true
    });

    fixture.detectChanges();
    const tooltip = fixture.debugElement.nativeElement.querySelector('ngb-tooltip-window');
    expect(tooltip).toBeTruthy()
  });

But the tooltip const is always null. It read that it might be an issue with animations and that I have to switch them off. But I couldn't find out how to.

My application displays the tooltip. It is inserted in the same container as the div when inspecting the Html.

Aucun commentaire:

Enregistrer un commentaire