-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] serialize null array items to string (#8083)
- Loading branch information
1 parent
2878466
commit ecd10b5
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
packages/-ember-data/tests/unit/utils/serialize-query-params-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { module, test } from 'qunit'; | ||
|
||
import { serializeQueryParams } from '@ember-data/adapter/-private'; | ||
|
||
module('Unit | serializeQueryParams', function () { | ||
test('it works', function (assert) { | ||
assert.expect(1); | ||
|
||
const qp = { | ||
filter: '%foo', | ||
}; | ||
const result = serializeQueryParams(qp); | ||
|
||
assert.deepEqual(result, 'filter=%25foo'); | ||
}); | ||
|
||
test('it works with nested', function (assert) { | ||
assert.expect(1); | ||
|
||
const qp = { | ||
filter: { | ||
children: [1, 2], | ||
}, | ||
}; | ||
const result = serializeQueryParams(qp); | ||
|
||
assert.deepEqual(result, 'filter%5Bchildren%5D%5B%5D=1&filter%5Bchildren%5D%5B%5D=2'); | ||
}); | ||
|
||
test('it treats null values in arrays as empty strings', function (assert) { | ||
assert.expect(1); | ||
|
||
const qp = { | ||
filter: { | ||
children: [null, 2], | ||
}, | ||
}; | ||
const result = serializeQueryParams(qp); | ||
|
||
assert.deepEqual(result, 'filter%5Bchildren%5D%5B%5D=&filter%5Bchildren%5D%5B%5D=2'); | ||
}); | ||
|
||
test('it works with + sign', function (assert) { | ||
assert.expect(1); | ||
|
||
const qp = { | ||
term: 'search me', | ||
}; | ||
const result = serializeQueryParams(qp); | ||
|
||
assert.deepEqual(result, 'term=search%20me'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters