jeudi 1 août 2019

How to test the following async function in angular?

code to test:

async showSuccess() {
  this.msgs.push({severity: 'success', summary: 'Success.'});
  await delay(1000);
  this.msgs = [];
}

here's the test I tried but await delay(1000) isn't covered and so isn't this.msgs = []

it('should show message', async() => {
        spyOn(component, 'showSuccess');
        component.showSuccess();
        expect(component.showSuccess).toHaveBeenCalled();
    });

The method signature line is covered and the msgs being pushed is covered but not the last two lines.

Aucun commentaire:

Enregistrer un commentaire