Skip to content
Advertisement

Karma-jasmine How i test a close function in a modal

I need to test this, but I’m new testing and I do not have idea, I’m working with angular, I just want to test the close function and maybe if it renders.

This is the html.

JavaScript

And this is the modal.component.ts

JavaScript

Advertisement

Answer

In order to test if EventEmitter emits an event when clicking on background div, you should write a test using spyOn like this:

JavaScript

Make sure you have access to component, by having these lines in beforeEach block:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement