@@ -174,6 +174,68 @@ test("Yields File's content", async t => {
174174 t . is < string > ( chunks . join ( "\n" ) , expected )
175175} )
176176
177+ test ( "Yields every appended file" , async t => {
178+ const expectedDisposition = "Content-Disposition: form-data; name=\"field\""
179+
180+ const fd = new FormData ( )
181+
182+ fd . append ( "field" , "Some string" )
183+ fd . append ( "field" , "Some other string" )
184+
185+ const iterable = readLine ( Readable . from ( new Encoder ( fd ) ) )
186+
187+ const { value : firstFieldDisposition } = await skip ( iterable , 2 )
188+
189+ t . is ( firstFieldDisposition , expectedDisposition )
190+
191+ const { value : firstFieldContent } = await skip ( iterable , 2 )
192+
193+ t . is ( firstFieldContent , "Some string" )
194+
195+ const { value : secondFieldDisposition } = await skip ( iterable , 2 )
196+
197+ t . is ( secondFieldDisposition , expectedDisposition )
198+
199+ const { value : secondFieldContent } = await skip ( iterable , 2 )
200+
201+ t . is ( secondFieldContent , "Some other string" )
202+ } )
203+
204+ test ( "Yields every appended File" , async t => {
205+ const expectedDisposition = "Content-Disposition: form-data; name=\"file\""
206+
207+ const fd = new FormData ( )
208+
209+ fd . append ( "file" , new File ( [ "Some content" ] , "file.txt" ) )
210+ fd . append ( "file" , new File ( [ "Some **content**" ] , "file.md" ) )
211+
212+ const iterable = readLine ( Readable . from ( new Encoder ( fd ) ) )
213+
214+ const { value : firstFileDisposition } = await skip ( iterable , 2 )
215+
216+ t . is ( firstFileDisposition , `${ expectedDisposition } ; filename="file.txt"` )
217+
218+ const { value : firstFileType } = await skip ( iterable )
219+
220+ t . is ( firstFileType , "Content-Type: text/plain" )
221+
222+ const { value : firstFileContent } = await skip ( iterable , 2 )
223+
224+ t . is ( firstFileContent , "Some content" )
225+
226+ const { value : secondFileDisposition } = await skip ( iterable , 2 )
227+
228+ t . is ( secondFileDisposition , `${ expectedDisposition } ; filename="file.md"` )
229+
230+ const { value : secondFileType } = await skip ( iterable )
231+
232+ t . is ( secondFileType , "Content-Type: text/markdown" )
233+
234+ const { value : secondFileContent } = await skip ( iterable , 2 )
235+
236+ t . is ( secondFileContent , "Some **content**" )
237+ } )
238+
177239test ( "Can be used with ReadableStream" , async t => {
178240 const fd = new FormData ( )
179241
0 commit comments