stackblitz示例:https://stackblitz.com/edit/angular-akhwj5?file=src%2Fapp%2Fapp.component.html
我正在尝试使用玩笑来测试此代码段,并且我不断得到返回值未覆盖的行
public temp:number;
EnterClicked = true;
@ViewChild('testFrom') testFrom :NgForm;
name = 'Angular';
public checkifTouchedAndDirtyAnd0()
{
return (this.testFrom.controls.inputfield.touched || this.testFrom.controls.inputfield.dirty || this.testFrom.controls.inputfield.valid) && this.EnterClicked;
}
html:
<form #testFrom="ngForm">
<input
[(ngModel)]="temp"
name="inputfield">
<div *ngIf="">
touched
</div>
</form>
**我如何在我的.spec文件中设置this.testFrom.controls.inputfield.dirty,.touched等...对象以测试函数调用的不同返回值?
更重要的是,我编写的类似代码具有9或条件,我是否必须测试每个单个组合才能开玩笑地将行标记为已覆盖?**