在Jasmine单元测试中的ReactiveForm(角度)中设置AbstractControl的值

时间:2019-03-22 15:21:34

标签: angular jasmine angular-reactive-forms

如何在Jasmine单元测试中的ReactiveForm中设置AbstractControl的值?

我的表单:

npm config set script-shell pwsh --userconfig ./.npmrc

我在茉莉花单元测试中的模拟:

this.formChangePassword = this.formBuilder.group({
  username: ['', [Validators.required]],
  oldpassword: ['', [Validators.required]],
  passwords: this.formBuilder.group({
    newpassword: ['', [Validators.required]],
    confirmpassword: ['', [Validators.required]]
  }, {validator: this.passwordConfirming})
});

我正在寻找在component.formChangePassword.controls.username.setValue('foo'); <= is OK component.formChangePassword.controls.passwords.controls.newpassword.setValue('newpwd'); <= is KO newpwd中写newpassword

AbstractControl

0 个答案:

没有答案