summaryrefslogtreecommitdiff
path: root/spec/frontend/search/index_spec.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 08:27:35 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 08:27:35 +0000
commit7e9c479f7de77702622631cff2628a9c8dcbc627 (patch)
treec8f718a08e110ad7e1894510980d2155a6549197 /spec/frontend/search/index_spec.js
parente852b0ae16db4052c1c567d9efa4facc81146e88 (diff)
downloadgitlab-ce-7e9c479f7de77702622631cff2628a9c8dcbc627.tar.gz
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/frontend/search/index_spec.js')
-rw-r--r--spec/frontend/search/index_spec.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/frontend/search/index_spec.js b/spec/frontend/search/index_spec.js
new file mode 100644
index 00000000000..8a86cc4c52a
--- /dev/null
+++ b/spec/frontend/search/index_spec.js
@@ -0,0 +1,47 @@
+import { initSearchApp } from '~/search';
+import createStore from '~/search/store';
+
+jest.mock('~/search/store');
+jest.mock('~/search/sidebar');
+jest.mock('~/search/group_filter');
+
+describe('initSearchApp', () => {
+ let defaultLocation;
+
+ const setUrl = query => {
+ window.location.href = `https://localhost:3000/search${query}`;
+ window.location.search = query;
+ };
+
+ beforeEach(() => {
+ defaultLocation = window.location;
+ Object.defineProperty(window, 'location', {
+ writable: true,
+ value: { href: '', search: '' },
+ });
+ });
+
+ afterEach(() => {
+ window.location = defaultLocation;
+ });
+
+ 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(() => {
+ setUrl(`?search=${search}`);
+ initSearchApp();
+ });
+
+ it(`decodes ${search} to ${decodedSearch}`, () => {
+ expect(createStore).toHaveBeenCalledWith({ query: { search: decodedSearch } });
+ });
+ });
+});