Skip to content

Commit 9bc9486

Browse files
committed
BN-31 | Fix. Remove Unused extractFirstUuidFromPath From Common Util
1 parent 67a571c commit 9bc9486

File tree

1 file changed

+1
-127
lines changed

1 file changed

+1
-127
lines changed

src/utils/__tests__/common.test.ts

Lines changed: 1 addition & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
extractFirstUuidFromPath,
3-
generateId,
4-
getFormattedError,
5-
} from '../common';
1+
import { generateId, getFormattedError } from '../common';
62
import axios, { AxiosError } from 'axios';
73

84
jest.mock('axios', () => ({
@@ -411,126 +407,4 @@ describe('common utility functions', () => {
411407
});
412408
});
413409
});
414-
415-
describe('extractFirstUuidFromPath', () => {
416-
// Happy path tests
417-
it('should extract UUID from a simple path', () => {
418-
const path = '/patients/123e4567-e89b-12d3-a456-426614174000';
419-
const result = extractFirstUuidFromPath(path);
420-
expect(result).toBe('123e4567-e89b-12d3-a456-426614174000');
421-
});
422-
423-
it('should extract UUID from a path with multiple segments', () => {
424-
const path =
425-
'/patients/123e4567-e89b-12d3-a456-426614174000/visits/recent';
426-
const result = extractFirstUuidFromPath(path);
427-
expect(result).toBe('123e4567-e89b-12d3-a456-426614174000');
428-
});
429-
430-
it('should extract UUID from the middle of a path', () => {
431-
const path =
432-
'/dashboard/patients/123e4567-e89b-12d3-a456-426614174000/profile';
433-
const result = extractFirstUuidFromPath(path);
434-
expect(result).toBe('123e4567-e89b-12d3-a456-426614174000');
435-
});
436-
437-
it('should extract UUID from the end of a path', () => {
438-
const path = '/dashboard/patients/123e4567-e89b-12d3-a456-426614174000';
439-
const result = extractFirstUuidFromPath(path);
440-
expect(result).toBe('123e4567-e89b-12d3-a456-426614174000');
441-
});
442-
443-
it('should extract UUID with uppercase characters', () => {
444-
const path = '/patients/123E4567-E89B-12D3-A456-426614174000';
445-
const result = extractFirstUuidFromPath(path);
446-
expect(result).toBe('123E4567-E89B-12D3-A456-426614174000');
447-
});
448-
449-
it('should extract UUID with mixed case characters', () => {
450-
const path = '/patients/123e4567-E89b-12D3-a456-426614174000';
451-
const result = extractFirstUuidFromPath(path);
452-
expect(result).toBe('123e4567-E89b-12D3-a456-426614174000');
453-
});
454-
455-
it('should extract the first UUID when multiple UUIDs are present', () => {
456-
const path =
457-
'/patients/123e4567-e89b-12d3-a456-426614174000/visits/98765432-abcd-efgh-ijkl-123456789012';
458-
const result = extractFirstUuidFromPath(path);
459-
expect(result).toBe('123e4567-e89b-12d3-a456-426614174000');
460-
});
461-
462-
it('should extract UUID from a path with query parameters', () => {
463-
const path =
464-
'/patients/123e4567-e89b-12d3-a456-426614174000?name=John&age=30';
465-
const result = extractFirstUuidFromPath(path);
466-
expect(result).toBe('123e4567-e89b-12d3-a456-426614174000');
467-
});
468-
469-
it('should extract UUID from a path with hash fragments', () => {
470-
const path = '/patients/123e4567-e89b-12d3-a456-426614174000#details';
471-
const result = extractFirstUuidFromPath(path);
472-
expect(result).toBe('123e4567-e89b-12d3-a456-426614174000');
473-
});
474-
475-
// Sad path tests
476-
it('should return null for null input', () => {
477-
const result = extractFirstUuidFromPath(null as unknown as string);
478-
expect(result).toBeNull();
479-
});
480-
481-
it('should return null for undefined input', () => {
482-
const result = extractFirstUuidFromPath(undefined as unknown as string);
483-
expect(result).toBeNull();
484-
});
485-
486-
it('should return null for empty string', () => {
487-
const result = extractFirstUuidFromPath('');
488-
expect(result).toBeNull();
489-
});
490-
491-
it('should return null for non-string input', () => {
492-
const result = extractFirstUuidFromPath(123 as unknown as string);
493-
expect(result).toBeNull();
494-
});
495-
496-
it('should return null for object input', () => {
497-
const result = extractFirstUuidFromPath({} as unknown as string);
498-
expect(result).toBeNull();
499-
});
500-
501-
it('should return null for array input', () => {
502-
const result = extractFirstUuidFromPath([] as unknown as string);
503-
expect(result).toBeNull();
504-
});
505-
506-
it('should return null for path without UUID', () => {
507-
const path = '/patients/list';
508-
const result = extractFirstUuidFromPath(path);
509-
expect(result).toBeNull();
510-
});
511-
512-
it('should return null for path with malformed UUID (missing segment)', () => {
513-
const path = '/patients/123e4567-e89b-12d3-a456';
514-
const result = extractFirstUuidFromPath(path);
515-
expect(result).toBeNull();
516-
});
517-
518-
it('should return null for path with malformed UUID (wrong format)', () => {
519-
const path = '/patients/123e4567-e89b-12d3-a456-42661417400Z'; // 'Z' is not a hex character
520-
const result = extractFirstUuidFromPath(path);
521-
expect(result).toBeNull();
522-
});
523-
524-
it('should return null for path with malformed UUID (missing hyphens)', () => {
525-
const path = '/patients/123e4567e89b12d3a456426614174000'; // No hyphens
526-
const result = extractFirstUuidFromPath(path);
527-
expect(result).toBeNull();
528-
});
529-
530-
it('should return null for path with UUID-like string but incorrect format', () => {
531-
const path = '/patients/not-a-real-uuid-but-has-hyphens';
532-
const result = extractFirstUuidFromPath(path);
533-
expect(result).toBeNull();
534-
});
535-
});
536410
});

0 commit comments

Comments
 (0)