Improved SearchBar test

This commit is contained in:
Alejandro Celaya
2021-11-08 23:23:45 +01:00
parent 3bc5b4c154
commit 5f33059de1
5 changed files with 88 additions and 65 deletions

View File

@@ -1,4 +1,4 @@
import { evolveStringifiedQuery, parseQuery, stringifyQuery } from '../../../src/utils/helpers/query';
import { parseQuery, stringifyQuery } from '../../../src/utils/helpers/query';
describe('query', () => {
describe('parseQuery', () => {
@@ -22,15 +22,4 @@ describe('query', () => {
expect(stringifyQuery(queryObj)).toEqual(expectedResult);
});
});
describe('evolveStringifiedQuery', () => {
it.each([
[ '?foo=bar', { baz: 123 }, 'foo=bar&baz=123' ],
[ 'foo=bar', { baz: 123 }, 'foo=bar&baz=123' ],
[ 'foo=bar&baz=hello', { baz: 'world' }, 'foo=bar&baz=world' ],
[ '?', { foo: 'some', bar: 'thing' }, 'foo=some&bar=thing' ],
])('adds and overwrites params on provided query string', (query, extra, expected) => {
expect(evolveStringifiedQuery(query, extra)).toEqual(expected);
});
});
});