我无法完成对ngForm提交的测试。我想检索提交表单后发送并传递给函数的表单值对象。我不确定是否可以检索它或模拟数据是否是标准做法。以下是我目前拥有的:
it('should record emit form values when clicked', () => {
const form = <NgForm>component.myForm;
const ascRadio = <HTMLInputElement>fixture.debugElement.nativeElement.querySelector("#myRadioButton");
ascRadio.checked = true;
const ascRadioValue = ascRadio.value;
const ev = new Event("submit");
form.onSubmit(ev);
fixture.detectChanges();
console.log(form);
expect(form.submitted).toBe(true);
})
我想在提交后获取表单值对象,因此:
expect(ascRadioValue).toEqual(emmittedValues.radioValue);
请告知...