mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
URL params serializer; (#4734)
* Refactored BuildURL helper to use URLSearchParams serializer; * Updated typings; Added TS test;
This commit is contained in:
@@ -17,7 +17,7 @@ describe('helpers::buildURL', function () {
|
||||
foo: {
|
||||
bar: 'baz'
|
||||
}
|
||||
})).toEqual('/foo?foo=' + encodeURI('{"bar":"baz"}'));
|
||||
})).toEqual('/foo?foo[bar]=baz');
|
||||
});
|
||||
|
||||
it('should support date params', function () {
|
||||
@@ -60,15 +60,6 @@ describe('helpers::buildURL', function () {
|
||||
})).toEqual('/foo?foo=bar&query=baz');
|
||||
});
|
||||
|
||||
it('should use serializer if provided', function () {
|
||||
serializer = sinon.stub();
|
||||
params = {foo: 'bar'};
|
||||
serializer.returns('foo=bar');
|
||||
expect(buildURL('/foo', params, serializer)).toEqual('/foo?foo=bar');
|
||||
expect(serializer.calledOnce).toBe(true);
|
||||
expect(serializer.calledWith(params)).toBe(true);
|
||||
});
|
||||
|
||||
it('should support URLSearchParams', function () {
|
||||
expect(buildURL('/foo', new URLSearchParams('bar=baz'))).toEqual('/foo?bar=baz');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user