@@ -10,6 +10,8 @@ describe("index.js", () => {
1010 const file1 = fs . readFileSync ( "test/fixture/dummy-data.json" ) ;
1111 const body = new FormData ( ) ;
1212 body . append ( "field1" , "value1" ) ;
13+ body . append ( "field2" , "value2" ) ;
14+ body . append ( "field3" , "value3" ) ;
1315 body . append ( "file1" , file1 ) ;
1416
1517 request = {
@@ -26,7 +28,7 @@ describe("index.js", () => {
2628
2729 it ( "should populate fields property" , async ( ) => {
2830 const { fields } = await parseMultipartFormData ( request ) ;
29- expect ( fields . length ) . toBe ( 1 ) ;
31+ expect ( fields . length ) . toBe ( 3 ) ;
3032 } ) ;
3133
3234 it ( "should populate files property" , async ( ) => {
@@ -47,4 +49,11 @@ describe("index.js", () => {
4749 await parseMultipartFormData ( request ) ;
4850 } ) . rejects . toThrow ( ) ;
4951 } ) ;
52+
53+ it ( "should accept options parameter, parse only one field" , async ( ) => {
54+ const { fields } = await parseMultipartFormData ( request , {
55+ limits : { fields : 1 } ,
56+ } ) ;
57+ expect ( fields . length ) . toBe ( 1 ) ;
58+ } ) ;
5059} ) ;
0 commit comments