Add tests for undefined query params

Fixes #169
This commit is contained in:
Michael Jackson
2019-07-30 15:51:14 -07:00
parent 699b849914
commit 7582c641fb
2 changed files with 10 additions and 3 deletions

View File

@ -5,6 +5,11 @@ describe('createSearch', () => {
expect(createSearch({ a: 'a', b: '' })).toEqual('?a=a&b');
});
it('omits the trailing = for null/undefined values', () => {
expect(createSearch({ a: 'a', b: null })).toEqual('?a=a&b');
expect(createSearch({ a: 'a', b: undefined })).toEqual('?a=a&b');
});
it('sorts keys', () => {
expect(createSearch({ b: 'b', a: 'a', c: 'c' })).toEqual('?a=a&b=b&c=c');
});