unpkg/modules/utils/__tests__/createSearch-test.js

16 lines
443 B
JavaScript
Raw Normal View History

2018-12-17 17:38:05 +00:00
const createSearch = require('../createSearch');
2018-05-26 00:22:59 +00:00
2018-12-17 17:38:05 +00:00
describe('createSearch', () => {
it('omits the trailing = for empty string values', () => {
expect(createSearch({ a: 'a', b: '' })).toEqual('?a=a&b');
2018-05-26 00:22:59 +00:00
});
2018-12-17 17:38:05 +00:00
it('sorts keys', () => {
expect(createSearch({ b: 'b', a: 'a', c: 'c' })).toEqual('?a=a&b=b&c=c');
2018-05-26 00:22:59 +00:00
});
2018-12-17 17:38:05 +00:00
it('returns an empty string when there are no params', () => {
expect(createSearch({})).toEqual('');
2018-05-26 00:22:59 +00:00
});
});