我想测试以下拦截器,以便验证:
@Injectable()
export class LoadingIndicatorInterceptor implements HttpInterceptor {
constructor(private loadingIndicatorService: LoadingIndicatorService) {}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
this.loadingIndicatorService.show(); // show()
return next.handle(req).pipe(
finalize(() => this.loadingIndicatorService.hide()) // hide()
);
}
}
如何测试这种拦截器的请求和响应行为?