-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lint:Fix the serialize query params test
- Loading branch information
1 parent
e62bd5d
commit dd0c220
Showing
1 changed file
with
13 additions
and
18 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,52 +1,47 @@ | ||
import { module, test } from 'qunit'; | ||
import { serializeQueryParams } from 'ember-fetch/utils/serialize-query-params'; | ||
|
||
|
||
module('Unit | serializeQueryParams', function() { | ||
test('serializeQueryParams turns deeply nested objects into queryParams like $.param', function(assert) { | ||
assert.expect(1); | ||
|
||
module('Unit | serializeQueryParams', function () { | ||
test('serializeQueryParams turns deeply nested objects into queryParams like $.param', function (assert) { | ||
const body = { | ||
a: 1, | ||
b: 2, | ||
c: { | ||
d: 3, | ||
e: { | ||
f: 4 | ||
f: 4, | ||
}, | ||
g: [5, 6, 7] | ||
} | ||
g: [5, 6, 7], | ||
}, | ||
}; | ||
const queryParamString = serializeQueryParams(body); | ||
|
||
assert.equal( | ||
assert.strictEqual( | ||
queryParamString, | ||
'a=1&b=2&c%5Bd%5D=3&c%5Be%5D%5Bf%5D=4&c%5Bg%5D%5B%5D=5&c%5Bg%5D%5B%5D=6&c%5Bg%5D%5B%5D=7' | ||
'a=1&b=2&c%5Bd%5D=3&c%5Be%5D%5Bf%5D=4&c%5Bg%5D%5B%5D=5&c%5Bg%5D%5B%5D=6&c%5Bg%5D%5B%5D=7', | ||
); | ||
}); | ||
|
||
test('serializeQueryParams does not serialize keys with undefined values', function(assert) { | ||
assert.expect(1); | ||
|
||
test('serializeQueryParams does not serialize keys with undefined values', function (assert) { | ||
const body = { | ||
a: undefined, | ||
b: 2, | ||
c: { | ||
d: undefined, | ||
e: { | ||
f: 4 | ||
f: 4, | ||
}, | ||
g: [5, 6, 7] | ||
g: [5, 6, 7], | ||
}, | ||
h: null, | ||
i: 0, | ||
j: false | ||
j: false, | ||
}; | ||
const queryParamString = serializeQueryParams(body); | ||
|
||
assert.equal( | ||
assert.strictEqual( | ||
queryParamString, | ||
'b=2&c%5Be%5D%5Bf%5D=4&c%5Bg%5D%5B%5D=5&c%5Bg%5D%5B%5D=6&c%5Bg%5D%5B%5D=7&h=&i=0&j=false' | ||
'b=2&c%5Be%5D%5Bf%5D=4&c%5Bg%5D%5B%5D=5&c%5Bg%5D%5B%5D=6&c%5Bg%5D%5B%5D=7&h=&i=0&j=false', | ||
); | ||
}); | ||
}); |