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:
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user