私のコンポーネントには、アニメーションが完了するまでの時間を与えるためにsetTimeout()
を含むclose関数があります。setTimeout()を含む関数のテスト
public close() {
this.animate = "inactive"
setTimeout(() => {
this.show = false
}, 250)
}
this.show
ngIf
にバインドされています。
this.animate
は、アニメーションにバインドされています。
私はsetTimeout()
がある場合にどのように適切にこの関数をテストするん
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)
})
この機能をテストする必要がテストを持っていますか?
私はjasmine.clock().tick(251)
を使用していましたが、ウィンドウは消えません。これについても考えていますか?
'done'を使ってみましたか? – jonrsharpe
@jonrsharpeどのくらい正確に –
あなたの研究を始めることをお勧めします。非同期プロセスをテストするためのものです。 – jonrsharpe