0
votes

Hi I am developing web application in angular. I have below code to open modal popup.

  this.formResetToggle = false;
        setTimeout(() => {
            this.formResetToggle = true;
            this.editorModal.show();
  });

I have written unit test case for the above modal to open the popup.

it('open modal', () => {
    expect(component.editorModal.isShown).toBe(false);
    component.addScope();
    expect(component.editorModal.isShown).toBe(true);
});

Initially editorModal.isShown will be false and when the modal is open editorModal.isShown will be true. This code works only when I remove settimeout from the addUser function. May I know what is reason and how can I fix this? Any help would be appreciated. Thank you.

1
why do you need to unit test a modal dialog? unit tests are for functions with logical operations. you could probably just test your modal with UI E2E tests - Sergio Alen

1 Answers

0
votes

Try this I hope it will work

formResetToggle :boolean=false
        setTimeout(() => {
            this.formResetToggle = true;
            this.editorModal.show();
  });