From d6c1fd33b8ec2effe665928971c3f84f160f4b32 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Fri, 9 Sep 2022 11:29:00 +0200
Subject: [PATCH] OZG-2844 OZG-2903 add check on empty string

---
 .../src/lib/user-profile.util.spec.ts                | 12 ++++++------
 .../user-profile-shared/src/lib/user-profile.util.ts |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/goofy-client/libs/user-profile-shared/src/lib/user-profile.util.spec.ts b/goofy-client/libs/user-profile-shared/src/lib/user-profile.util.spec.ts
index ae917f16f9..85fd335924 100644
--- a/goofy-client/libs/user-profile-shared/src/lib/user-profile.util.spec.ts
+++ b/goofy-client/libs/user-profile-shared/src/lib/user-profile.util.spec.ts
@@ -7,20 +7,20 @@ describe('UserProfileUtil', () => {
 
 	describe('existsName', () => {
 
-		it('should return true if only firstName exists', () => {
-			const exists: boolean = existsName({ ...createUserProfileResource(), lastName: null });
+		it.each([null, EMPTY_STRING])('should return true if only firstName exists and lastName has value %s', (value: null | string) => {
+			const exists: boolean = existsName({ ...createUserProfileResource(), lastName: value });
 
 			expect(exists).toBeTruthy();
 		})
 
-		it('should return true if only lastName exists', () => {
-			const exists: boolean = existsName({ ...createUserProfileResource(), firstName: null });
+		it.each([null, EMPTY_STRING])('should return true if only lastName exists and firstName has value %s', (value: null | string) => {
+			const exists: boolean = existsName({ ...createUserProfileResource(), firstName: value });
 
 			expect(exists).toBeTruthy();
 		})
 
-		it('should return false if either firstName nor lastName exists', () => {
-			const exists: boolean = existsName({ ...createUserProfileResource(), firstName: null, lastName: null });
+		it.each([null, EMPTY_STRING])('should return false if either firstName nor lastName exists', (value: null | string) => {
+			const exists: boolean = existsName({ ...createUserProfileResource(), firstName: value, lastName: value });
 
 			expect(exists).toBeFalsy();
 		})
diff --git a/goofy-client/libs/user-profile-shared/src/lib/user-profile.util.ts b/goofy-client/libs/user-profile-shared/src/lib/user-profile.util.ts
index b9c72b2074..1746fece6f 100644
--- a/goofy-client/libs/user-profile-shared/src/lib/user-profile.util.ts
+++ b/goofy-client/libs/user-profile-shared/src/lib/user-profile.util.ts
@@ -1,4 +1,4 @@
-import { EMPTY_STRING, getFirstLetter, getStringValue, isNotNull } from '@goofy-client/tech-shared';
+import { EMPTY_STRING, getFirstLetter, getStringValue, isNotEmpty, isNotNull } from '@goofy-client/tech-shared';
 import { isNull } from 'lodash-es';
 import { UserProfileResource } from './user-profile.model';
 
@@ -6,7 +6,7 @@ export const NO_NAME_MESSAGE: string = 'Benutzer ohne hinterlegtem Namen';
 export const UNKNOWN_USER: string = 'Unbekannter Benutzer';
 
 export function existsName(userProfile: UserProfileResource): boolean {
-	return isNotNull(userProfile.firstName) || isNotNull(userProfile.lastName);
+	return (isNotEmpty(userProfile.firstName) && isNotNull(userProfile.firstName)) || (isNotEmpty(userProfile.lastName) && isNotNull(userProfile.lastName));
 }
 
 export function getUserName(userProfile: UserProfileResource): string {
-- 
GitLab