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

OZG-5717: remove unnecessary null check and fix tests

parent fc054e49
No related branches found
No related tags found
No related merge requests found
......@@ -185,6 +185,8 @@ describe('BescheidenFormService', () => {
[BescheidenFormService.FIELD_BEWILLIGT]: String(bescheidResource.bewilligt),
[BescheidenFormService.FIELD_BESCHEID_DOCUMENT]: null,
[BescheidenFormService.FIELD_SEND_BY]: String(bescheidResource.sendBy),
[BescheidenFormService.FIELD_NACHRICHT_SUBJECT]: bescheidResource.nachrichtSubject,
[BescheidenFormService.FIELD_NACHRICHT_TEXT]: bescheidResource.nachrichtText,
});
});
......@@ -205,7 +207,7 @@ describe('BescheidenFormService', () => {
[BescheidenFormService.FIELD_SEND_BY]: BescheidSendBy.NACHRICHT,
[BescheidenFormService.FIELD_BESCHEID_DOCUMENT]: bescheidDocumentUri,
[BescheidenFormService.FIELD_NACHRICHT_SUBJECT]: bescheidResource.nachrichtSubject,
[BescheidenFormService.FIELD_NACHRICHT_TEXT]: bescheidResource.nachrichtSubject,
[BescheidenFormService.FIELD_NACHRICHT_TEXT]: bescheidResource.nachrichtText,
});
});
......@@ -340,12 +342,6 @@ describe('BescheidenFormService', () => {
expect(service.getValue().nachrichtSubject).toEqual(documentResource.nachrichtSubject);
});
it('should patch nachrichtSubject with default value if document not exists', () => {
service.patchNachricht(null);
expect(service.getValue().nachrichtSubject).toEqual(BescheidenFormService.BETREFF_DEFAULT);
});
it.each([EMPTY_STRING, null, undefined])(
'should patch nachrichtSubject with default value if subject not defined',
(subject: string) => {
......@@ -378,14 +374,6 @@ describe('BescheidenFormService', () => {
expect(service.getValue().nachrichtText).toEqual(documentResource.nachrichtText);
});
it('should build Nachricht Text if document not exists', () => {
service.buildNachrichtentext = jest.fn();
service.patchNachricht(null);
expect(service.buildNachrichtentext).toHaveBeenCalled();
});
it.each([EMPTY_STRING, null, undefined])(
'should build Nachricht Text if text not defined',
(text: string) => {
......@@ -401,15 +389,6 @@ describe('BescheidenFormService', () => {
},
);
it('should patch nachrichtText with default value if document not exists', () => {
const nachrichtText = faker.lorem.text();
service.buildNachrichtentext = jest.fn().mockReturnValue(nachrichtText);
service.patchNachricht(null);
expect(service.getValue().nachrichtText).toEqual(nachrichtText);
});
it.each([EMPTY_STRING, null, undefined])(
'should patch nachrichtText with default value if text not defined',
(text: string) => {
......
......@@ -267,10 +267,10 @@ export class BescheidenFormService extends AbstractFormService implements OnDest
return this.sendByManual.asObservable();
}
public patchNachricht(documentResource?: DocumentResource): void {
public patchNachricht(documentResource: DocumentResource): void {
const value = this.getValue();
if (isEmpty(value.nachrichtSubject)) {
if (documentResource && isNotEmpty(documentResource.nachrichtSubject)) {
if (isNotEmpty(documentResource.nachrichtSubject)) {
this.setNachrichtSubject(documentResource.nachrichtSubject);
} else {
this.setNachrichtSubject(BescheidenFormService.BETREFF_DEFAULT);
......@@ -278,7 +278,7 @@ export class BescheidenFormService extends AbstractFormService implements OnDest
}
if (isEmpty(value.nachrichtText)) {
if (documentResource && isNotEmpty(documentResource.nachrichtText)) {
if (isNotEmpty(documentResource.nachrichtText)) {
this.setNachrichtText(documentResource.nachrichtText);
} else {
this.setNachrichtText(this.buildNachrichtentext());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment