Files
remark42/frontend/app/utils/parseQuery.test.ts
T
Pavel MineevandGitHub 85c71716f9 Small refactoring (#609)
* Move visibility param from redux store to local state

* use func for parsing location.search

* Remove bad wrapper

* we already have wrapper with NODE_ID on page and we shouldn't another one with the same id on page
* move common part of markup to level up

* Tinny refac of setSorting

* add dummy types for pollyfils

also, a bit rewrited way to resolve imports

* Move sort flag to local store

Because we don't need to share this param between diffrent parts of interface

* Add action creators

* move action to action creators

* Remove unused functions

* Merge in conditions in one

* One way for export API methods

* add default tags

* Rewrited changing read only mode

* removed unused function

* set sort changes

* always send sort from store
* rollback if sort don't  work

* constanst

* add typing
* shorten export
* remove double define of host
2020-03-07 12:25:18 -06:00

25 lines
744 B
TypeScript

import parseQuery from './parseQuery';
describe('parseQuery', () => {
it('should return empty object', () => {
expect(parseQuery('')).toEqual({});
expect(parseQuery('?')).toEqual({});
});
it('should add empty field to object', () => {
expect(parseQuery('?a')).toEqual({ a: '' });
});
it('should add empty field and field with param to object', () => {
expect(parseQuery('?a&b=1')).toEqual({ a: '', b: '1' });
});
it('should add all params to object', () => {
expect(parseQuery('?a=1&b=1')).toEqual({ a: '1', b: '1' });
});
it('should convert urlencoded param', () => {
expect(parseQuery('?x=%D1%8B%D1%84%D0%B2%D0%B0%D1%84%D1%8B%D0%B2%D1%84%D1%8B')).toEqual({ x: 'ыфвафывфы' });
});
});