From 7effd0f458663f5af821fb96b0dd23ef32b43e43 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Thu, 26 Jun 2025 18:43:10 +0200 Subject: simplest test --- webAO/__tests__/paths.test.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 webAO/__tests__/paths.test.ts (limited to 'webAO/__tests__') diff --git a/webAO/__tests__/paths.test.ts b/webAO/__tests__/paths.test.ts new file mode 100644 index 0000000..fa1a2d0 --- /dev/null +++ b/webAO/__tests__/paths.test.ts @@ -0,0 +1,31 @@ +import { getFilenameFromPath } from '../utils/paths'; + +// Test Case 1: Valid Path with Filename +test('should return the filename for a valid path', () => { + const result = getFilenameFromPath('/path/to/file.txt'); + expect(result).toBe('file.txt'); +}); + +// Test Case 2: Path without File Extension +test('should handle paths without file extension', () => { + const result = getFilenameFromPath('/path/to/file'); + expect(result).toBe('file'); +}); + +// Test Case 3: Empty String +test('should return an empty string if input is empty', () => { + const result = getFilenameFromPath(''); + expect(result).toBe(''); +}); + +// Test Case 4: Path with Multiple Slashes +test('should handle paths with multiple consecutive slashes', () => { + const result = getFilenameFromPath('//path//to///file.txt'); + expect(result).toBe('file.txt'); +}); + +// Test Case 5: No Filename in Path +test('should return an empty string if there is no filename in the path', () => { + const result = getFilenameFromPath('/path/to/'); + expect(result).toBe(''); +}); -- cgit