@@ -6,27 +6,26 @@ globalThis.fetch = vi.fn()
66describe ( 'getHyperparamSource' , ( ) => {
77 const endpoint = 'http://localhost:3000'
88
9- test . for ( [
10- 'test.txt' ,
11- 'no-extension' ,
12- 'folder/subfolder/test.txt' ,
13- ] ) ( 'recognizes a local file path' , ( sourceId : string ) => {
14- expect ( getHyperparamSource ( sourceId , { endpoint } ) ?. kind ) . toBe ( 'file' )
9+ it ( 'recognizes local files' , ( ) => {
10+ expect ( getHyperparamSource ( 'test.txt' , { endpoint } ) ?. kind ) . toBe ( 'file' )
11+ expect ( getHyperparamSource ( 'no-extension' , { endpoint } ) ?. kind ) . toBe ( 'file' )
12+ expect ( getHyperparamSource ( 'folder/subfolder/test.txt' , { endpoint } ) ?. kind ) . toBe ( 'file' )
1513 } )
1614
17- test . for ( [
18- '' ,
19- 'folder1/' ,
20- 'folder1/folder2/' ,
21- ] ) ( 'recognizes a folder' , ( sourceId : string ) => {
22- expect ( getHyperparamSource ( sourceId , { endpoint } ) ?. kind ) . toBe ( 'directory' )
15+ it ( 'recognizes folders' , ( ) => {
16+ expect ( getHyperparamSource ( '' , { endpoint } ) ?. kind ) . toBe ( 'directory' )
17+ expect ( getHyperparamSource ( 'folder1/' , { endpoint } ) ?. kind ) . toBe ( 'directory' )
18+ expect ( getHyperparamSource ( 'folder1/folder2/' , { endpoint } ) ?. kind ) . toBe ( 'directory' )
2319 } )
2420
25- test . for ( [
26- '/' ,
27- '////' ,
28- ] ) ( 'does not support a heading slash' , ( sourceId : string ) => {
29- expect ( getHyperparamSource ( sourceId , { endpoint } ) ) . toBeUndefined ( )
21+ it ( 'throws on leading slash' , ( ) => {
22+ expect ( ( ) => getHyperparamSource ( '/' , { endpoint } ) ) . toThrow ( 'Source cannot start with a /' )
23+ expect ( ( ) => getHyperparamSource ( '/folder/' , { endpoint } ) ) . toThrow ( 'Source cannot start with a /' )
24+ } )
25+
26+ it ( 'throws on .. in path' , ( ) => {
27+ expect ( ( ) => getHyperparamSource ( '..' , { endpoint } ) ) . toThrow ( 'Source cannot include ..' )
28+ expect ( ( ) => getHyperparamSource ( 'folder/../file.txt' , { endpoint } ) ) . toThrow ( 'Source cannot include ..' )
3029 } )
3130
3231 test . for ( [
0 commit comments