Skip to content

Commit 55898c8

Browse files
Ruben van LeeuwenDutchBen
authored andcommitted
Fix type expected by uuid function
1 parent 86b504f commit 55898c8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

packages/orchestrator-ui-components/src/utils/uuid.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ describe('getFirstUuidPart()', () => {
55
const result = getFirstUuidPart('12345678-1234-1234-1234-123456789abc');
66
expect(result).toEqual('12345678');
77
});
8+
9+
it('returns empty string for empty uuid', () => {
10+
const result = getFirstUuidPart();
11+
expect(result).toEqual('');
12+
});
813
});
914

1015
describe('isUuid4()', () => {

packages/orchestrator-ui-components/src/utils/uuid.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
export const getFirstUuidPart = (uuid: string): string => uuid.slice(0, 8);
1+
export const getFirstUuidPart = (uuid?: string): string =>
2+
uuid ? uuid.slice(0, 8) : '';
23

34
export const isUuid4 = (value: string): boolean =>
45
!!value.match(

0 commit comments

Comments
 (0)