【发布时间】:2019-03-27 10:47:07
【问题描述】:
我有一个 Angular 4 应用程序,我正在使用 angular2-chartjs 在我的应用程序中绘制图表。
在组件中,我导入了以下内容:
import { ChartComponent } from 'angular2-chartjs';
import { ChartModule } from 'angular2-chartjs';
创建了图表属性:
@ViewChild(ChartComponent) chart: ChartComponent;
现在我将这个图表对象从组件传递给服务的方法:
this.chartService.updateChartWith(this.chart);
现在在图表服务中,我正在更新图表:
public updateChartWith(chart: ChartComponent) {
/** Some code **/
chart.chart.update();
}
图表完美运行。我想为 Jasmine 中的 updateChartWith() 方法编写单元测试。如何为 Jasmine 中的 chart.chart.update() 行代码编写单元测试?
【问题讨论】: