Description: update test for formidable 3
Author: Yadd <yadd@debian.org>
Forwarded: not-needed
Last-Update: 2022-07-17

--- a/test/unit/adapters/http.js
+++ b/test/unit/adapters/http.js
@@ -12,9 +12,8 @@
 let server, proxy;
 import AxiosError from '../../../lib/core/AxiosError.js';
 import FormData from 'form-data';
-import formidable from 'formidable';
+import {IncomingForm} from 'formidable';
 import express from 'express';
-import multer from 'multer';
 import bodyParser from 'body-parser';
 const isBlobSupported = typeof Blob !== 'undefined';
 import {Throttle} from 'stream-throttle';
@@ -1515,7 +1514,7 @@
       });
 
       server = http.createServer(function (req, res) {
-        var receivedForm = new formidable.IncomingForm();
+        var receivedForm = new IncomingForm();
 
         receivedForm.parse(req, function (err, fields, files) {
           if (err) {
@@ -1533,54 +1532,17 @@
             'Content-Type': 'multipart/form-data'
           }
         }).then(function (res) {
-          assert.deepStrictEqual(res.data.fields, {foo: 'bar'});
+          assert.deepStrictEqual(res.data.fields, {foo: ['bar']});
 
-          assert.strictEqual(res.data.files.file1.mimetype, 'image/jpeg');
-          assert.strictEqual(res.data.files.file1.originalFilename, 'temp/bar.jpg');
-          assert.strictEqual(res.data.files.file1.size, 3);
+          assert.strictEqual(res.data.files.file1[0].mimetype, 'image/jpeg');
+          assert.strictEqual(res.data.files.file1[0].originalFilename, 'temp/bar.jpg');
+          assert.strictEqual(res.data.files.file1[0].size, 3);
 
           done();
         }).catch(done);
       });
     });
 
-    describe('toFormData helper', function () {
-      it('should properly serialize nested objects for parsing with multer.js (express.js)', function (done) {
-        var app = express();
-
-        var obj = {
-          arr1: ['1', '2', '3'],
-          arr2: ['1', ['2'], '3'],
-          obj: {x: '1', y: {z: '1'}},
-          users: [{name: 'Peter', surname: 'griffin'}, {name: 'Thomas', surname: 'Anderson'}]
-        };
-
-        app.post('/', multer().none(), function (req, res, next) {
-          res.send(JSON.stringify(req.body));
-        });
-
-        server = app.listen(3001, function () {
-          // multer can parse the following key/value pairs to an array (indexes: null, false, true):
-          // arr: '1'
-          // arr: '2'
-          // -------------
-          // arr[]: '1'
-          // arr[]: '2'
-          // -------------
-          // arr[0]: '1'
-          // arr[1]: '2'
-          // -------------
-          Promise.all([null, false, true].map(function (mode) {
-            return axios.postForm('http://localhost:3001/', obj, {formSerializer: {indexes: mode}})
-              .then(function (res) {
-                assert.deepStrictEqual(res.data, obj, 'Index mode ' + mode);
-              });
-          })).then(function (){
-            done();
-          }, done)
-        });
-      });
-    });
   });
 
   describe('URLEncoded Form', function () {
