File: update-test-for-formidable-3.patch

package info (click to toggle)
node-axios 1.2.1%2Bdfsg-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,796 kB
  • sloc: javascript: 10,727; makefile: 5
file content (86 lines) | stat: -rw-r--r-- 3,072 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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 () {