File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
packages/components/test/lib Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 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+ } )
You can’t perform that action at this time.
0 commit comments