mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-28 16:00:24 +05:30
#337: properly serialize null values in request.buildQuery
This commit is contained in:
parent
59000926ab
commit
41661dbea5
@ -114,7 +114,7 @@ function doFetch(url, options = {}) {
|
|||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
function convertQueryValue(value) {
|
function convertQueryValue(value) {
|
||||||
if (typeof value === 'undefined') {
|
if (typeof value === 'undefined' || value === null) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,12 +57,13 @@ describe('services/request', () => {
|
|||||||
it('should build query', () => {
|
it('should build query', () => {
|
||||||
const data = {
|
const data = {
|
||||||
notSet: undefined,
|
notSet: undefined,
|
||||||
|
notSet2: null,
|
||||||
numeric: 1,
|
numeric: 1,
|
||||||
complexString: 'sdfgs sdfg ',
|
complexString: 'sdfgs sdfg ',
|
||||||
positive: true,
|
positive: true,
|
||||||
negative: false
|
negative: false
|
||||||
};
|
};
|
||||||
const expectedQs = 'notSet=&numeric=1&complexString=sdfgs%20sdfg%20&positive=1&negative=0';
|
const expectedQs = 'notSet=¬Set2=&numeric=1&complexString=sdfgs%20sdfg%20&positive=1&negative=0';
|
||||||
|
|
||||||
expect(request.buildQuery(data), 'to equal', expectedQs);
|
expect(request.buildQuery(data), 'to equal', expectedQs);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user