I'm trying to Unit test a method in my Angular application. I have written a test that passes and checks two elements - the global variable returns true and the method is called. I am not sure what else I could test here but the line is still not covered.
.ts file
clickout(event) {
this.isActive = this.eRef.nativeElement.contains(event.target); //not covered!
}
.html file
<div (document:click)="clickout($event)" id="clickout" class="actions__container">
click me
</div>
.spec file
it('should call func and return true', fakeAsync(() => {
component.isActive = true;
fixture.detectChanges();
spyOn(component, 'clickout');
let btn = fixture.debugElement.nativeElement.querySelector('#clickout');
btn.click();
tick();
fixture.detectChanges();
expect(component.clickout).toHaveBeenCalled();
expect(component.isActive).toBe(true);
}));
How can I firm up this test? I assume its because I am not looking to see if .nativeElement is containing something? Any help appreciated. I have created this stackBlitz example with jasmine installed.