0
我有以下代码,我需要知道如何在测试中使用spyon
和previousValue
和currentValue
来覆盖条件if (cur !== prev && cur === 100)
。在Angular 2中使用SimpleChanges测试ngOnChanges
ngOnChanges(changes: SimpleChanges) {
if (changes['highlightData'] && !changes['highlightData'].isFirstChange()) {
const prev: any = changes['highlightData'].previousValue;
const cur: any = changes['highlightData'].currentValue;
if (cur !== prev && cur === 100) {
this._render.setElementClass(this._elementRef.nativeElement, 'animate', true);
setTimeout(() => {
this._render.setElementClass(this._elementRef.nativeElement, 'animate', false);
}, 3000);
}
}
}
有谁知道我该怎么做? 谢谢。