Skip to content

Commit 04011bf

Browse files
committed
test(query): test null values
1 parent 058217f commit 04011bf

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: test/unit/specs/query.spec.js

+16
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ describe('Query utils', () => {
99
baz: 'qux'
1010
}))
1111
})
12+
13+
it('should turn empty params into null', () => {
14+
expect(resolveQuery('?foo&bar=&arr=1&arr&arr=2')).toEqual({
15+
foo: null,
16+
bar: '',
17+
arr: ['1', null, '2']
18+
})
19+
})
1220
})
1321

1422
describe('stringifyQuery', () => {
@@ -20,6 +28,14 @@ describe('Query utils', () => {
2028
})).toBe('?foo=bar&baz=qux&arr=1&arr=2')
2129
})
2230

31+
it('should add only the key with null', () => {
32+
expect(stringifyQuery({
33+
foo: null,
34+
bar: '',
35+
arr: [1, null, 3]
36+
})).toBe('?foo&bar=&arr=1&arr&arr=3')
37+
})
38+
2339
it('should escape reserved chars', () => {
2440
expect(stringifyQuery({
2541
a: '*()!'

0 commit comments

Comments
 (0)