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

OZG-5769 null safe check

parent 59550572
Branches
Tags
No related merge requests found
...@@ -128,5 +128,14 @@ describe('VorgangDetailBescheidenResultNachrichtComponent', () => { ...@@ -128,5 +128,14 @@ describe('VorgangDetailBescheidenResultNachrichtComponent', () => {
expect(formService.patchNachricht).not.toHaveBeenCalled(); expect(formService.patchNachricht).not.toHaveBeenCalled();
}); });
it.each([null, undefined])(
'should not patch form if document resource is %s',
(resource: DocumentResource) => {
component.bescheidDocumentStateResource = createStateResource(resource);
expect(formService.patchNachricht).not.toHaveBeenCalled();
},
);
}); });
}); });
import { BescheidService, DocumentResource } from '@alfa-client/bescheid-shared'; import { BescheidService, DocumentResource } from '@alfa-client/bescheid-shared';
import { StateResource } from '@alfa-client/tech-shared'; import { StateResource, isNotNil } from '@alfa-client/tech-shared';
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms'; import { FormGroup } from '@angular/forms';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
...@@ -11,7 +11,7 @@ import { BescheidenFormService } from '../../bescheiden.formservice'; ...@@ -11,7 +11,7 @@ import { BescheidenFormService } from '../../bescheiden.formservice';
}) })
export class VorgangDetailBescheidenResultNachrichtComponent implements OnInit { export class VorgangDetailBescheidenResultNachrichtComponent implements OnInit {
@Input() set bescheidDocumentStateResource(stateResource: StateResource<DocumentResource>) { @Input() set bescheidDocumentStateResource(stateResource: StateResource<DocumentResource>) {
if (!stateResource.loading && !stateResource.error) { if (!stateResource.loading && !stateResource.error && isNotNil(stateResource.resource)) {
this.formService.patchNachricht(stateResource.resource); this.formService.patchNachricht(stateResource.resource);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment