UNPKG

moy-router

Version:

Give a solution for moy-dom router management.

47 lines (41 loc) 1.09 kB
import { parseQuery, stringifyQuery } from 'src/utils/Query' describe('test for parseQuery', () => { test('parseQuery "a=1&b=2" should be {a: "1", b: "2"}', () => { expect(parseQuery('a=1&b=2')).toEqual({ a: '1', b: '2', }) }) test('parseQuery "a=&b=2" should be {a: "", b: "2"}', () => { expect(parseQuery('a=&b=2')).toEqual({ a: '', b: '2', }) }) test('parseQuery "a=%20%40&b=2" should be {a: " @", b: "2"}', () => { expect(parseQuery('a=%20%40&b=2')).toEqual({ a: ' @', b: '2', }) }) }) describe('test for stringifyQuery', () => { test('stringifyQuery {a: "1", b: "2"} should be "?a=1&b=2"', () => { expect(stringifyQuery({ a: '1', b: '2', })).toBe('?a=1&b=2') }) test('stringifyQuery {a: "", b: "2"} should be "?a=&b=2', () => { expect(stringifyQuery({ a: '', b: '2', })).toBe('?a=&b=2') }) test('stringifyQuery {a: " @", b: "2"} should be "?a=%20%40&b=2"', () => { expect(stringifyQuery({ a: ' @', b: '2', })).toBe('?a=%20%40&b=2') }) })