【发布时间】:2018-05-13 02:02:46
【问题描述】:
我的 .ts 文件中有 2 个方法
export class VehicleSaleInfoComponent implements OnInit, OnDestroy {
dealerBlock = true;
constructor(){}
ngOnInit() {}
runList() {
this.dealerBlock = false;
}
Dealer() {
this.dealerBlock = true;
}
}
我的 .spec 文件
it('should Show RunList Component exist', () => {
expect(component.runList);
// fixture.detectChanges();
expect(component.dealerBlock, 'false').to.be.false;
});
it('should show DealerBlock Component exist', () => {
expect(component.Dealer);
expect(component.dealerBlock).to.be.true;
});
错误: 车辆销售信息组件 × Show RunList 组件是否存在 PhantomJS 2.1.1 (Windows 8 0.0.0) false:预期 true 为 false
它不会选择方法内的值...任何方法来获取方法内的值。
【问题讨论】:
-
是这样写的.. it('应该显示RunList组件存在', () => { component.dealerBlock = false; expect(component.runList); // fixture.detectChanges();期望(component.dealerBlock, 'false').to.be.false; });但我不知道它的正确方式......
-
expect(component.runList)应该做什么? -
expect(component.runList).to.be.exist;
标签: angular unit-testing karma-runner karma-mocha