以下是代码示例:
this.paymentTypesService.updatePaymentTypesOrder('cashout', newOrder).subscribe(() => {
this.notificationsService.success(
'Success!',
`Order change saved successfully`,
{ showProgressBar: true, pauseOnHover: true, clickToClose: true }
);
}, () => {
this.notificationsService.error(
'Error',
`Order change save failed`,
{ showProgressBar: true, pauseOnHover: true, clickToClose: true }
);
});
paymentTypesService
方法背后有简单的Http服务......在这种情况下我应该如何测试错误处理程序?
答案 0 :(得分:0)
这样的事情应该有效:
spyOn(paymentTypesService, 'updatePaymentTypesOrder').and.returnValue(Observable.throw(new Error()))