2021-01-22 04:08:53 -05:00
|
|
|
import setHighlightClass from 'ee_else_ce/search/highlight_blob_search_result';
|
2021-07-27 08:10:54 -04:00
|
|
|
import setWindowLocation from 'helpers/set_window_location_helper';
|
2020-11-16 19:09:16 -05:00
|
|
|
import { initSearchApp } from '~/search';
|
|
|
|
import createStore from '~/search/store';
|
|
|
|
|
|
|
|
jest.mock('~/search/store');
|
2020-12-03 16:09:35 -05:00
|
|
|
jest.mock('~/search/topbar');
|
2020-11-16 19:09:16 -05:00
|
|
|
jest.mock('~/search/sidebar');
|
2021-01-22 04:08:53 -05:00
|
|
|
jest.mock('ee_else_ce/search/highlight_blob_search_result');
|
2020-11-16 19:09:16 -05:00
|
|
|
|
|
|
|
describe('initSearchApp', () => {
|
|
|
|
describe.each`
|
|
|
|
search | decodedSearch
|
|
|
|
${'test'} | ${'test'}
|
|
|
|
${'%2520'} | ${'%20'}
|
|
|
|
${'test%2Bthis%2Bstuff'} | ${'test+this+stuff'}
|
|
|
|
${'test+this+stuff'} | ${'test this stuff'}
|
|
|
|
${'test+%2B+this+%2B+stuff'} | ${'test + this + stuff'}
|
|
|
|
${'test%2B+%2Bthis%2B+%2Bstuff'} | ${'test+ +this+ +stuff'}
|
|
|
|
${'test+%2520+this+%2520+stuff'} | ${'test %20 this %20 stuff'}
|
|
|
|
`('parameter decoding', ({ search, decodedSearch }) => {
|
|
|
|
beforeEach(() => {
|
2021-07-27 08:10:54 -04:00
|
|
|
setWindowLocation(`/search?search=${search}`);
|
2020-11-16 19:09:16 -05:00
|
|
|
initSearchApp();
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`decodes ${search} to ${decodedSearch}`, () => {
|
|
|
|
expect(createStore).toHaveBeenCalledWith({ query: { search: decodedSearch } });
|
2021-01-22 04:08:53 -05:00
|
|
|
expect(setHighlightClass).toHaveBeenCalledWith(decodedSearch);
|
2020-11-16 19:09:16 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|