fix: fix interceptors

This commit is contained in:
2025-02-03 23:53:49 +08:00
parent eacbbb2815
commit 26a06fdbf0
7 changed files with 291 additions and 68 deletions

View File

@@ -1,9 +1,21 @@
import { HttpFeatureKind } from '@ngify/http';
import { HttpClientTestingBackend } from '@ngify/http/testing';
import { InjectionToken, type Provider } from 'injection-js';
import { HTTP_BACKEND, provideHttpClient } from 'oidc-client-rx';
export function provideHttpClientTesting() {
return {
provide: HttpFeatureKind.Backend,
useClass: HttpClientTestingBackend,
};
export const HTTP_CLIENT_TEST_CONTROLLER =
new InjectionToken<HttpClientTestingBackend>('HTTP_CLIENT_TEST_CONTROLLER');
export function provideHttpClientTesting(): Provider[] {
const backend = new HttpClientTestingBackend();
return [
{
provide: HTTP_CLIENT_TEST_CONTROLLER,
useValue: backend,
},
{
provide: HTTP_BACKEND,
useValue: backend,
},
...provideHttpClient(),
];
}

View File

@@ -6,4 +6,4 @@ export {
} from './spy';
export { createRetriableStream } from './create-retriable-stream.helper';
export { MockRouter, mockRouterProvider } from './router';
export { provideHttpClientTesting } from './http';
export { provideHttpClientTesting, HTTP_CLIENT_TEST_CONTROLLER } from './http';