【发布时间】:2018-10-05 10:33:15
【问题描述】:
我有一个 Angular (6) HttpInterceptor,就像这个拦截方法一样:
intercept(req: HttpRequest<any>,next: HttpHandler): Observable<HttpEvent<any>> {
if (this.translationService.currentLang) {
req = req.clone({
setHeaders: {
'Accept-Language': this.translationService.currentLang
}
});
}
return next.handle(req);
}
如何使用 jasmine 进行单元测试并检查返回的请求是否包含新标头?我知道我可以使用
获取参数let next = jasmine.createSpyObj('httpHandler', ['handle']);
next.handle.calls.mostRecent();
但是如何验证标头是否已设置?
【问题讨论】:
标签: angular typescript unit-testing jasmine