Skip to content

Commit 4cb5411

Browse files
authored
add tests for parseKey (#91)
1 parent 44efd56 commit 4cb5411

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { describe, expect, test } from 'vitest'
2+
import { parseKey } from '../../src/lib/key.js'
3+
4+
describe('parseKey', () => {
5+
test.for([
6+
'test.txt',
7+
'no-extension',
8+
'folder/subfolder/test.txt',
9+
])('recognizes a local file path', (key: string) => {
10+
const parsedKey = parseKey(key, { apiBaseUrl: 'http://localhost:3000' })
11+
expect(parsedKey.kind).toBe('file')
12+
})
13+
14+
test.for([
15+
'',
16+
'/',
17+
'////',
18+
'folder1/',
19+
'folder1/folder2/',
20+
])('recognizes a folder', (key: string) => {
21+
const parsedKey = parseKey(key, { apiBaseUrl: 'http://localhost:3000' })
22+
expect(parsedKey.kind).toBe('folder')
23+
})
24+
25+
test.for([
26+
'http://example.com/test.txt',
27+
'https://example.com/test.txt',
28+
'http://weird',
29+
'https%3A%2F%2Fhyperparam-public.s3.amazonaws.com%2Fbunnies.parquet',
30+
])('recognizes a URL', (key: string) => {
31+
const parsedKey = parseKey(key, { apiBaseUrl: 'http://localhost:3000' })
32+
expect(parsedKey.kind).toBe('url')
33+
})
34+
})

0 commit comments

Comments
 (0)