【发布时间】:2017-06-20 18:44:20
【问题描述】:
我有下面的代码,我需要知道如何在我的测试中使用spyon 和previousValue 和currentValue 来覆盖条件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);
}
}
}
有人知道我该怎么做吗? 谢谢。
【问题讨论】:
标签: karma-jasmine angular2-directives angular2-testing