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

OZG-2844 OZG-2903 add check on empty string

parent c26cbe60
No related branches found
No related tags found
No related merge requests found
...@@ -7,20 +7,20 @@ describe('UserProfileUtil', () => { ...@@ -7,20 +7,20 @@ describe('UserProfileUtil', () => {
describe('existsName', () => { describe('existsName', () => {
it('should return true if only firstName exists', () => { 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: null }); const exists: boolean = existsName({ ...createUserProfileResource(), lastName: value });
expect(exists).toBeTruthy(); expect(exists).toBeTruthy();
}) })
it('should return true if only lastName exists', () => { 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: null }); const exists: boolean = existsName({ ...createUserProfileResource(), firstName: value });
expect(exists).toBeTruthy(); expect(exists).toBeTruthy();
}) })
it('should return false if either firstName nor lastName exists', () => { it.each([null, EMPTY_STRING])('should return false if either firstName nor lastName exists', (value: null | string) => {
const exists: boolean = existsName({ ...createUserProfileResource(), firstName: null, lastName: null }); const exists: boolean = existsName({ ...createUserProfileResource(), firstName: value, lastName: value });
expect(exists).toBeFalsy(); expect(exists).toBeFalsy();
}) })
......
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 { isNull } from 'lodash-es';
import { UserProfileResource } from './user-profile.model'; import { UserProfileResource } from './user-profile.model';
...@@ -6,7 +6,7 @@ export const NO_NAME_MESSAGE: string = 'Benutzer ohne hinterlegtem Namen'; ...@@ -6,7 +6,7 @@ export const NO_NAME_MESSAGE: string = 'Benutzer ohne hinterlegtem Namen';
export const UNKNOWN_USER: string = 'Unbekannter Benutzer'; export const UNKNOWN_USER: string = 'Unbekannter Benutzer';
export function existsName(userProfile: UserProfileResource): boolean { 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 { export function getUserName(userProfile: UserProfileResource): string {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment