我正在尝试测试这样的拦截器服务:
<img src='data:image/png;base64," . {{ $png }} . "'>
只需将这2个标头添加到我在应用程序中执行的所有Http调用中即可。
我知道要测试拦截器是否添加标题,我必须执行以下操作:
import { Injectable } from '@angular/core';
import { HttpInterceptor } from '@angular/common/http';
@Injectable()
export class ChacheCtrlInterceptor implements HttpInterceptor {
constructor() { }
intercept(req, next) {
let httpCall = req.clone({
headers: req.headers.set('Pragma', 'no-cache')
.set('Cache-Control', 'no-cache')
});
return next.handle(httpCall);
}
}
任何想法我该如何覆盖此代码,我是业力测试的新手:S