aboutsummaryrefslogtreecommitdiff
path: root/webAO/__tests__/paths.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'webAO/__tests__/paths.test.ts')
-rw-r--r--webAO/__tests__/paths.test.ts31
1 files changed, 31 insertions, 0 deletions
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('');
+});