I have a close function in my component that contains a setTimeout()
in order to give time for the animation to complete.
public close() {
this.animate = "inactive"
setTimeout(() => {
this.show = false
}, 250)
}
this.show
is bound to an ngIf
.
this.animate
is bound to an animation.
I have a test that needs to test this function
it("tests the exit button click", () => {
comp.close()
fixture.detectChanges()
//verifies the element is no longer in the DOM
const popUpWindow = fixture.debugElement.query(By.css("#popup-window"))
expect(popUpWindow).toEqual(null)
})
How do you properly test this function when there is a setTimeout()
?
I was using jasmine.clock().tick(251)
but the window would never disappear. any thoughts on this as well?