Skip to content

Commit

Permalink
Deprecate pipe and interceptor external utilities (#61)
Browse files Browse the repository at this point in the history
* Deprecate `testPipeValues`

* Deprecate `makeInterceptorSucceed` and `makeInterceptorFail`
  • Loading branch information
remscodes authored Feb 7, 2024
1 parent fc61db6 commit c4ec4aa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
export * from './models';
export { interceptorTestBed } from './interceptor-test-bed';
export {
makeInterceptorSucceed,
makeInterceptorFail,
} from './tools/interceptor';

2 changes: 2 additions & 0 deletions projects/ngx-testing-tools/src/lib/v3-removed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ export { emitOutput } from '../component-test-bed/tools/action/utils/output';
export { emitFakeSuccessResponse } from '../common/tools/http/utils/emit-success-response';
export { emitFakeErrorResponse } from '../common/tools/http/utils/emit-error-response';
export { expectHttpRequest } from './expect-http-response';

export { makeInterceptorSucceed, makeInterceptorFail } from './interceptor';
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { HttpErrorResponse, HttpHandlerFn, HttpInterceptorFn, HttpRequest } from '@angular/common/http';
import { Observable, of, throwError } from 'rxjs';
import { ErrorInterceptorConfig, SuccessInterceptorConfig } from '../../common/tools/http/utils/models/interceptor-config.model';
import { ErrorInterceptorConfig, SuccessInterceptorConfig } from '../common/tools/http/utils/models/interceptor-config.model';

function mockSuccessHandlerFnFactory(): HttpHandlerFn {
return (req: HttpRequest<unknown>) => of(req) as any;
}

/** @deprecated Use the `InterceptorTestBed` with `InspectTools` instead. Will be removed in v3. */
export function makeInterceptorSucceed(interceptor: HttpInterceptorFn, config: SuccessInterceptorConfig = {}): Observable<HttpRequest<unknown>> {
const { url = '/test', method = 'GET' } = config;
const req = new HttpRequest<unknown>(method, url, null);
Expand All @@ -17,6 +18,7 @@ function mockErrorHandlerFnFactory(err: HttpErrorResponse): HttpHandlerFn {
return () => throwError(() => err);
}

/** @deprecated Use the `InterceptorTestBed` with `InspectTools` instead. Will be removed in v3. */
export function makeInterceptorFail(interceptor: HttpInterceptorFn, config: ErrorInterceptorConfig = {}): Observable<HttpRequest<unknown>> {
const { url = '/test', status = 500 } = config;
const req = new HttpRequest<unknown>('GET', url);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PipeTransform } from '@angular/core';

/** @deprecated Use the `PipeTestBed` with `VerifyTools` instead. Will be removed in v3. */
export function testPipeValues<T extends PipeTransform>(pipe: T, record: Record<any, string>): void {
Object.entries(record).forEach(([current, expected]: [any, string]) => {
it(`should transform "${current}" to "${expected}"`, () => {
Expand Down

0 comments on commit c4ec4aa

Please sign in to comment.