blob: 76137b806fd4f3174c4e8126b542a2b75d66185f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import { parseQuery as parseQueryGlobal, objectToQuery } from './url'
const parseQuery = search =>
parseQueryGlobal({
search
})
test('parseQuery', () => {
expect(parseQuery('?mySearch=myVal')).toEqual({ mySearch: 'myVal' })
expect(parseQuery('?mySearch=myVal&againWith=aVal')).toEqual({
mySearch: 'myVal',
againWith: 'aVal'
})
// test that these 2 functions are inverses
// (e.g composing them produces `const f = k => k`)
let input = '?big=long&one=eh'
expect(objectToQuery(parseQuery(input))).toEqual(input)
input = { args: 'hi', onArgs: 'helloagain' }
expect(parseQuery(objectToQuery(input))).toEqual(input)
})
|