I have the code below and I need to know how I could use spyon
with previousValue
and currentValue
in my test to coverage the conditional if (cur !== prev && cur === 100)
.
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);
}
}
}
Does anyone know how can I do that? Thanks.