2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-08 17:22:34 +03:00

Release/0.21.4 (#4025)

* fix json transform when data is pre-stringified (#4020)

* [Updating] incorrect JSON syntax in README.md

* [Releasing] v0.21.4

Co-authored-by: Guillaume FORTAINE <guillaume+github@fortaine.com>
This commit is contained in:
Jay
2021-09-06 17:35:06 +02:00
committed by GitHub
parent 90205f8ab7
commit 4091b075f6
10 changed files with 66 additions and 11 deletions
+13
View File
@@ -20,6 +20,19 @@ describe('defaults', function () {
expect(defaults.transformRequest[0]({foo: 'bar'})).toEqual('{"foo":"bar"}');
});
it("should also transform request json when 'Content-Type' is 'application/json'", function () {
var headers = {
'Content-Type': 'application/json',
};
expect(defaults.transformRequest[0](JSON.stringify({ foo: 'bar' }), headers)).toEqual('{"foo":"bar"}');
expect(defaults.transformRequest[0]([42, 43], headers)).toEqual('[42,43]');
expect(defaults.transformRequest[0]('foo', headers)).toEqual('"foo"');
expect(defaults.transformRequest[0](42, headers)).toEqual('42');
expect(defaults.transformRequest[0](true, headers)).toEqual('true');
expect(defaults.transformRequest[0](false, headers)).toEqual('false');
expect(defaults.transformRequest[0](null, headers)).toEqual('null');
});
it('should do nothing to request string', function () {
expect(defaults.transformRequest[0]('foo=bar')).toEqual('foo=bar');
});