@@ -1208,128 +1208,6 @@ describe('Treaty2 - SSE Chunk Splitting (fast streaming edge cases)', () => {
12081208 { event : 'third' , data : 3 }
12091209 ] )
12101210 } )
1211- } )
1212-
1213- describe ( 'Treaty2 - Using t.File() and t.Files() from server' , async ( ) => {
1214- const filePath1 = `${ import . meta. dir } /public/aris-yuzu.jpg`
1215- const filePath2 = `${ import . meta. dir } /public/midori.png`
1216- const filePath3 = `${ import . meta. dir } /public/kyuukurarin.mp4`
1217-
1218- const bunFile1 = Bun . file ( filePath1 )
1219- const bunFile2 = Bun . file ( filePath2 )
1220- const bunFile3 = Bun . file ( filePath3 )
1221-
1222- const file1 = new File ( [ await bunFile1 . arrayBuffer ( ) ] , 'cumin.webp' , {
1223- type : 'image/webp'
1224- } )
1225- const file2 = new File ( [ await bunFile2 . arrayBuffer ( ) ] , 'curcuma.jpg' , {
1226- type : 'image/jpeg'
1227- } )
1228- const file3 = new File ( [ await bunFile3 . arrayBuffer ( ) ] , 'kyuukurarin.mp4' , {
1229- type : 'video/mp4'
1230- } )
1231-
1232- const filesForm = new FormData ( )
1233- filesForm . append ( 'files' , file1 )
1234- filesForm . append ( 'files' , file2 )
1235- filesForm . append ( 'files' , file3 )
1236-
1237- const bunFilesForm = new FormData ( )
1238- bunFilesForm . append ( 'files' , bunFile1 )
1239- bunFilesForm . append ( 'files' , bunFile2 )
1240- bunFilesForm . append ( 'files' , bunFile3 )
1241-
1242- it ( 'accept a single Bun.file' , async ( ) => {
1243- const { data : files } = await client . files . post ( {
1244- files : bunFile1 as unknown as File [ ]
1245- } )
1246-
1247- expect ( files ) . not . toBeNull ( )
1248- expect ( files ) . not . toBeUndefined ( )
1249- expect ( files ) . toEqual ( [ bunFile1 . name ! ] )
1250-
1251- const { data : filesbis } = await client . files . post ( {
1252- files : [ bunFile1 ] as unknown as File [ ]
1253- } )
1254-
1255- expect ( filesbis ) . not . toBeNull ( )
1256- expect ( filesbis ) . not . toBeUndefined ( )
1257- expect ( filesbis ) . toEqual ( [ bunFile1 . name ! ] )
1258-
1259- const { data : file } = await client . file . post ( {
1260- file : bunFile1 as unknown as File
1261- } )
1262-
1263- expect ( file ) . not . toBeNull ( )
1264- expect ( file ) . not . toBeUndefined ( )
1265- expect ( file ) . toEqual ( bunFile1 . name ! )
1266- } )
1267-
1268- it ( 'accept a single regular file' , async ( ) => {
1269- const { data : files } = await client . files . post ( {
1270- files : file1 as unknown as File [ ]
1271- } )
1272-
1273- expect ( files ) . not . toBeNull ( )
1274- expect ( files ) . not . toBeUndefined ( )
1275- expect ( files ) . toEqual ( [ file1 . name ! ] )
1276-
1277- const { data : filesbis } = await client . files . post ( {
1278- files : [ file1 ] as unknown as File [ ]
1279- } )
1280-
1281- expect ( filesbis ) . not . toBeNull ( )
1282- expect ( filesbis ) . not . toBeUndefined ( )
1283- expect ( filesbis ) . toEqual ( [ file1 . name ! ] )
1284-
1285- const { data : file } = await client . file . post ( {
1286- file : file1 as unknown as File
1287- } )
1288-
1289- expect ( file ) . not . toBeNull ( )
1290- expect ( file ) . not . toBeUndefined ( )
1291- expect ( file ) . toEqual ( file1 . name ! )
1292- } )
1293-
1294- it ( 'accept an array of multiple Bun.file' , async ( ) => {
1295- const { data : files } = await client . files . post ( {
1296- files : [ bunFile1 , bunFile2 , bunFile3 ] as unknown as File [ ]
1297- } )
1298-
1299- expect ( files ) . not . toBeNull ( )
1300- expect ( files ) . not . toBeUndefined ( )
1301- expect ( files ) . toEqual ( [ bunFile1 . name ! , bunFile2 . name ! , bunFile3 . name ! ] )
1302-
1303- const { data : filesbis } = await client . files . post ( {
1304- files : bunFilesForm . getAll ( 'files' ) as unknown as File [ ]
1305- } )
1306-
1307- expect ( filesbis ) . not . toBeNull ( )
1308- expect ( filesbis ) . not . toBeUndefined ( )
1309- expect ( filesbis ) . toEqual ( [
1310- bunFile1 . name ! ,
1311- bunFile2 . name ! ,
1312- bunFile3 . name !
1313- ] )
1314- } )
1315-
1316- it ( 'accept an array of multiple regular file' , async ( ) => {
1317- const { data : files } = await client . files . post ( {
1318- files : [ file1 , file2 , file3 ] as unknown as File [ ]
1319- } )
1320-
1321- expect ( files ) . not . toBeNull ( )
1322- expect ( files ) . not . toBeUndefined ( )
1323- expect ( files ) . toEqual ( [ file1 . name ! , file2 . name ! , file3 . name ! ] )
1324-
1325- const { data : filesbis } = await client . files . post ( {
1326- files : filesForm . getAll ( 'files' ) as unknown as File [ ]
1327- } )
1328-
1329- expect ( filesbis ) . not . toBeNull ( )
1330- expect ( filesbis ) . not . toBeUndefined ( )
1331- expect ( filesbis ) . toEqual ( [ file1 . name ! , file2 . name ! , file3 . name ! ] )
1332- } )
13331211
13341212 it ( 'handle root dynamic parameter' , async ( ) => {
13351213 const app = new Elysia ( ) . get ( '/:id' , ( { params : { id } } ) => id , {
0 commit comments