Skip to content
Snippets Groups Projects
Commit 10b8c2d2 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-3574 Handle empty error (2)

parent 30de7e11
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen * Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
import { HttpErrorResponse } from '@angular/common/http';
import { faker } from '@faker-js/faker'; import { faker } from '@faker-js/faker';
import { ApiRootService } from '@goofy-client/api-root-shared'; import { ApiRootService } from '@goofy-client/api-root-shared';
import { CommandListResource, CommandResource, CommandService } from '@goofy-client/command-shared'; import { CommandListResource, CommandResource, CommandService } from '@goofy-client/command-shared';
...@@ -32,8 +33,9 @@ import { cold } from 'jest-marbles'; ...@@ -32,8 +33,9 @@ import { cold } from 'jest-marbles';
import { createBinaryFileListResource } from 'libs/binary-file-shared/test/binary-file'; import { createBinaryFileListResource } from 'libs/binary-file-shared/test/binary-file';
import { CommandLinkRel } from 'libs/command-shared/src/lib/command.linkrel'; import { CommandLinkRel } from 'libs/command-shared/src/lib/command.linkrel';
import { createCommandListResource, createCommandResource } from 'libs/command-shared/test/command'; import { createCommandListResource, createCommandResource } from 'libs/command-shared/test/command';
import { createHttpErrorResponse } from 'libs/tech-shared/test/error';
import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang'; import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang';
import { of } from 'rxjs'; import { EMPTY, EmptyError, Observable, of, throwError } from 'rxjs';
import { VorgangFacade } from './+state/vorgang.facade'; import { VorgangFacade } from './+state/vorgang.facade';
import { VorgangRepository } from './+state/vorgang.repository'; import { VorgangRepository } from './+state/vorgang.repository';
import { VorgangWithEingangLinkRel } from './vorgang.linkrel'; import { VorgangWithEingangLinkRel } from './vorgang.linkrel';
...@@ -109,6 +111,16 @@ describe('VorgangService', () => { ...@@ -109,6 +111,16 @@ describe('VorgangService', () => {
expect(repository.getVorgang).toHaveBeenCalledWith(url); expect(repository.getVorgang).toHaveBeenCalledWith(url);
}) })
it('should call handleError', () => {
const errorResponse: HttpErrorResponse = createHttpErrorResponse();
repository.getVorgang.mockReturnValue(throwError(() => new Error(errorResponse.error)));
service.handleError = jest.fn();
service.loadVorgangWithEingang(url);
expect(service.handleError).toHaveBeenCalled();
})
it('should update vorgang', () => { it('should update vorgang', () => {
service.updateVorgang = jest.fn(); service.updateVorgang = jest.fn();
const vorgangWithEingang: VorgangWithEingangResource = createVorgangWithEingangResource(); const vorgangWithEingang: VorgangWithEingangResource = createVorgangWithEingangResource();
...@@ -120,6 +132,22 @@ describe('VorgangService', () => { ...@@ -120,6 +132,22 @@ describe('VorgangService', () => {
}) })
}) })
describe('handleError', () => {
it('should call setVorgangWithEingang', () => {
service.setVorgangWithEingang = jest.fn();
service.handleError();
expect(service.setVorgangWithEingang).toHaveBeenCalled();
})
it('should return EMPTY', () => {
const result: Observable<EmptyError> = service.handleError();
expect(result).toBe(EMPTY);
})
})
describe('updateVorgang', () => { describe('updateVorgang', () => {
beforeEach(() => { beforeEach(() => {
......
...@@ -31,7 +31,7 @@ import { PostfachOrder } from '@goofy-client/postfach-shared'; ...@@ -31,7 +31,7 @@ import { PostfachOrder } from '@goofy-client/postfach-shared';
import { ApiError, createEmptyStateResource, createErrorStateResource, createStateResource, doIfLoadingRequired, isNotNil, isNotNull, isNotUndefined, StateResource } from '@goofy-client/tech-shared'; import { ApiError, createEmptyStateResource, createErrorStateResource, createStateResource, doIfLoadingRequired, isNotNil, isNotNull, isNotUndefined, StateResource } from '@goofy-client/tech-shared';
import { getUrl, hasLink, ResourceUri } from '@ngxp/rest'; import { getUrl, hasLink, ResourceUri } from '@ngxp/rest';
import { CommandLinkRel } from 'libs/command-shared/src/lib/command.linkrel'; import { CommandLinkRel } from 'libs/command-shared/src/lib/command.linkrel';
import { BehaviorSubject, combineLatest, EMPTY, Observable, Subscription } from 'rxjs'; import { BehaviorSubject, combineLatest, EMPTY, EmptyError, Observable, Subscription } from 'rxjs';
import { catchError, first, map, startWith, tap } from 'rxjs/operators'; import { catchError, first, map, startWith, tap } from 'rxjs/operators';
import { VorgangFacade } from './+state/vorgang.facade'; import { VorgangFacade } from './+state/vorgang.facade';
import { VorgangRepository } from './+state/vorgang.repository'; import { VorgangRepository } from './+state/vorgang.repository';
...@@ -94,7 +94,7 @@ export class VorgangService { ...@@ -94,7 +94,7 @@ export class VorgangService {
).subscribe((vorgang: VorgangWithEingangResource) => this.updateVorgang(vorgang)); ).subscribe((vorgang: VorgangWithEingangResource) => this.updateVorgang(vorgang));
} }
handleError(): Observable<ApiError> { handleError(): Observable<EmptyError> {
this.setVorgangWithEingang(createErrorStateResource(<ApiError>{})); this.setVorgangWithEingang(createErrorStateResource(<ApiError>{}));
return EMPTY; return EMPTY;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment