我需要以下代码的代码覆盖率的帮助。我不确定如何进入下面突出显示的代码
submitContactForm(): void {
const contactData: ContactData = {
'name': this.name.value,
'email': this.email.value,
'subject': this.subject.value,
'description': this.description.value,
'userId': null,
'siteSource': this.authService.getSiteSource()
};
***this.xyzService.submitQuery(contactData).subscribe(
resp => {
console.log('Contact Us got a positive response');
console.log(resp);
this.alertService.success('Success', 'Your message has been sent successfully. We will reply to you as soon as possible');
},
err => {
this.alertService.showAlert(err);
console.log('Contact Us got a ERROR response');
console.log(err);
}***
);
}
答案 0 :(得分:0)
尝试类似的东西:
component.submitContactForm()
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(result).toEqual(desiredValue);
});