@@ -89,6 +89,17 @@ export const test = test => {
8989 assert . equal ( file2 . lastModified , 123 , "lastModified should be 123" )
9090 } )
9191
92+ // This mimics the payload sent by a browser when a file input
93+ // exists but is not filled out.
94+ test ( "filename on string contents" , ( ) => {
95+ const formData = new FormData ( )
96+ formData . set ( "file-3" , new Blob ( [ ] ) , "" )
97+ const file3 = /** @type {File } */ ( formData . get ( "file-3" ) )
98+ assert . equal ( file3 . constructor . name , "File" )
99+ assert . equal ( file3 . name , "" )
100+ assert . equal ( file3 . type , "" )
101+ } )
102+
92103 test ( "throws on few args" , ( ) => {
93104 const data = new FormData ( )
94105 // @ts -expect-error
@@ -207,21 +218,21 @@ export const test = test => {
207218 assert . deepEqual ( [ ...data ] , [ [ "n2" , "v2" ] ] )
208219 } )
209220
210- test ( "Shold return correct filename with File" , ( ) => {
221+ test ( "Should return correct filename with File" , ( ) => {
211222 const data = new FormData ( )
212223 data . set ( "key" , new File ( [ ] , "doc.txt" ) )
213224 const file = /** @type {File } */ ( data . get ( "key" ) )
214225 assert . equal ( "doc.txt" , file . name )
215226 } )
216227
217- test ( "Shold return correct filename with Blob filename" , ( ) => {
228+ test ( "Should return correct filename with Blob filename" , ( ) => {
218229 const data = new FormData ( )
219230 data . append ( "key" , new Blob ( ) , "doc.txt" )
220231 const file = /** @type {File } */ ( data . get ( "key" ) )
221232 assert . equal ( "doc.txt" , file . name )
222233 } )
223234
224- test ( "Shold return correct filename with just Blob" , ( ) => {
235+ test ( "Should return correct filename with just Blob" , ( ) => {
225236 const data = new FormData ( )
226237 data . append ( "key" , new Blob ( ) )
227238 const file = /** @type {File } */ ( data . get ( "key" ) )
0 commit comments