【发布时间】:2018-06-19 12:14:21
【问题描述】:
这里是我需要测试的ts文件,Karma中未发现的代码只有下面一行
(value => {
this.value = ++this.value;
});
我是 Angular 新手,对单元测试完全陌生,请帮忙
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
import { ToolHandlerService } from '../shared/services/toolhandler.service';
import { ISubscription } from 'rxjs/Subscription';
@Component({
selector: 'basic-graphicresults',
templateUrl: './graphicresults.component.html',
styleUrls: ['./graphicresults.component.scss']
})
export class GraphicResultsComponent implements OnInit, OnDestroy {
@Input() value: number;
private replaceResultsSubscription: ISubscription;
constructor(private toolHandlerService: ToolHandlerService) {
}
ngOnInit() {
this.value=4;
this.replaceResultsSubscription = this.toolHandlerService.onReplaceResults$.subscribe(value => {
this.value = ++this.value;
});
}
ngOnDestroy() {
this.replaceResultsSubscription.unsubscribe();
}
}
【问题讨论】:
标签: angular unit-testing visual-studio-code karma-jasmine