debian-mirror-gitlab/spec/frontend/search/index_spec.js

33 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
import setHighlightClass from 'ee_else_ce/search/highlight_blob_search_result';
2021-10-27 15:23:28 +05:30
import setWindowLocation from 'helpers/set_window_location_helper';
2021-01-29 00:20:46 +05:30
import { initSearchApp } from '~/search';
import createStore from '~/search/store';
jest.mock('~/search/store');
2021-02-22 17:27:13 +05:30
jest.mock('~/search/topbar');
2021-01-29 00:20:46 +05:30
jest.mock('~/search/sidebar');
2021-03-11 19:13:27 +05:30
jest.mock('ee_else_ce/search/highlight_blob_search_result');
2021-01-29 00:20:46 +05:30
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-10-27 15:23:28 +05:30
setWindowLocation(`/search?search=${search}`);
2021-01-29 00:20:46 +05:30
initSearchApp();
});
it(`decodes ${search} to ${decodedSearch}`, () => {
expect(createStore).toHaveBeenCalledWith({ query: { search: decodedSearch } });
2021-03-11 19:13:27 +05:30
expect(setHighlightClass).toHaveBeenCalledWith(decodedSearch);
2021-01-29 00:20:46 +05:30
});
});
});