Skip to content

Commit

Permalink
Lint:Fix the serialize query params test
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Nov 6, 2024
1 parent e62bd5d commit dd0c220
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions test-app/tests/unit/utils/serialize-query-params-test.js
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',
);
});
});

0 comments on commit dd0c220

Please sign in to comment.