@@ -89,6 +89,17 @@ export const test = test => {
89
89
assert . equal ( file2 . lastModified , 123 , "lastModified should be 123" )
90
90
} )
91
91
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
+
92
103
test ( "throws on few args" , ( ) => {
93
104
const data = new FormData ( )
94
105
// @ts -expect-error
@@ -207,21 +218,21 @@ export const test = test => {
207
218
assert . deepEqual ( [ ...data ] , [ [ "n2" , "v2" ] ] )
208
219
} )
209
220
210
- test ( "Shold return correct filename with File" , ( ) => {
221
+ test ( "Should return correct filename with File" , ( ) => {
211
222
const data = new FormData ( )
212
223
data . set ( "key" , new File ( [ ] , "doc.txt" ) )
213
224
const file = /** @type {File } */ ( data . get ( "key" ) )
214
225
assert . equal ( "doc.txt" , file . name )
215
226
} )
216
227
217
- test ( "Shold return correct filename with Blob filename" , ( ) => {
228
+ test ( "Should return correct filename with Blob filename" , ( ) => {
218
229
const data = new FormData ( )
219
230
data . append ( "key" , new Blob ( ) , "doc.txt" )
220
231
const file = /** @type {File } */ ( data . get ( "key" ) )
221
232
assert . equal ( "doc.txt" , file . name )
222
233
} )
223
234
224
- test ( "Shold return correct filename with just Blob" , ( ) => {
235
+ test ( "Should return correct filename with just Blob" , ( ) => {
225
236
const data = new FormData ( )
226
237
data . append ( "key" , new Blob ( ) )
227
238
const file = /** @type {File } */ ( data . get ( "key" ) )
0 commit comments