2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

Fixed merge conflicts

This commit is contained in:
Jay
2022-04-01 18:40:12 +02:00
22 changed files with 644 additions and 161 deletions
+45 -1
View File
@@ -10,6 +10,8 @@ var path = require('path');
var pkg = require('./../../../package.json');
var server, proxy;
var AxiosError = require('../../../lib/core/AxiosError');
var FormData = require('form-data');
var formidable = require('formidable');
describe('supports http with nodejs', function () {
@@ -519,7 +521,7 @@ describe('supports http with nodejs', function () {
it('should display error while parsing params', function (done) {
server = http.createServer(function () {
}).listen(4444, function () {
axios.get('http://localhost:4444/', {
params: {
@@ -1182,5 +1184,47 @@ describe('supports http with nodejs', function () {
});
});
});
it('should allow passing FormData', function (done) {
var form = new FormData();
var file1= Buffer.from('foo', 'utf8');
form.append('foo', "bar");
form.append('file1', file1, {
filename: 'bar.jpg',
filepath: 'temp/bar.jpg',
contentType: 'image/jpeg'
});
server = http.createServer(function (req, res) {
var receivedForm = new formidable.IncomingForm();
receivedForm.parse(req, function (err, fields, files) {
if (err) {
return done(err);
}
res.end(JSON.stringify({
fields: fields,
files: files
}));
});
}).listen(4444, function () {
axios.post('http://localhost:4444/', form, {
headers: {
'Content-Type': 'multipart/form-data'
}
}).then(function (res) {
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);
done();
}).catch(done);
});
});
});
+12
View File
@@ -0,0 +1,12 @@
var assert = require('assert');
var isFormData = require('../../../lib/utils').isFormData;
var FormData = require('form-data');
describe('utils::isFormData', function () {
it('should detect the FormData instance provided by the `form-data` package', function () {
[1, 'str', {}, new RegExp()].forEach(function (thing) {
assert.equal(isFormData(thing), false);
});
assert.equal(isFormData(new FormData()), true);
});
});