我将如何进行测试? http方法和subscribe方法中的部分。我会将一些逻辑提取到服务中,但是我没有选择。我使用的是角6,使用的是因果和茉莉。
export class ProviderSubTypeAddEditComponent implements OnInit {
onSubmit() {
if (!this.isedit) {
this.httpClient.post(`${e.serverURL}${this.url}`,
{
name: this.form.get('providerTypeLabel').value,
provider_type: this.form.get('selectedOption').value,
})
.subscribe(
data => {
this.saveaction.emit(true);
this.snotifyService.async('Kindly wait ...', this.successAction).eventEmitter.subscribe(d =>{
if(d === 'hidden'){
if (this.hasback){
this.router.navigateByUrl('/provider_sub_types/list');
}
}
});
},
error => {
this.snotifyService.error("An Error Occured. Kindly contact support.")
},
);
} else {
// patch action
this.httpClient.patch(`${e.serverURL}${this.url}${this.providerid}/`,
{
name: this.form.get('providerTypeLabel').value,
provider_type: this.form.get('selectedOption').value,
})
.subscribe(
data => {
this.patchaction.emit(true);
this.snotifyService.success("Provider subtype edited successfully.")
},
error => {
this.snotifyService.error("An Error Occured. Kindly contact support.")
},
);
}
}
}
任何帮助将不胜感激。谢谢。