summaryrefslogtreecommitdiff
path: root/spec/frontend/filtered_search
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/filtered_search')
-rw-r--r--spec/frontend/filtered_search/filtered_search_manager_spec.js12
-rw-r--r--spec/frontend/filtered_search/visual_token_value_spec.js8
2 files changed, 12 insertions, 8 deletions
diff --git a/spec/frontend/filtered_search/filtered_search_manager_spec.js b/spec/frontend/filtered_search/filtered_search_manager_spec.js
index c03c8f6c529..83e7f6c9b3f 100644
--- a/spec/frontend/filtered_search/filtered_search_manager_spec.js
+++ b/spec/frontend/filtered_search/filtered_search_manager_spec.js
@@ -8,12 +8,14 @@ import IssuableFilteredSearchTokenKeys from '~/filtered_search/issuable_filtered
import RecentSearchesRoot from '~/filtered_search/recent_searches_root';
import RecentSearchesService from '~/filtered_search/services/recent_searches_service';
import RecentSearchesServiceError from '~/filtered_search/services/recent_searches_service_error';
-import * as commonUtils from '~/lib/utils/common_utils';
+import createFlash from '~/flash';
import { BACKSPACE_KEY_CODE, DELETE_KEY_CODE } from '~/lib/utils/keycodes';
-import { visitUrl } from '~/lib/utils/url_utility';
+import { visitUrl, getParameterByName } from '~/lib/utils/url_utility';
+jest.mock('~/flash');
jest.mock('~/lib/utils/url_utility', () => ({
...jest.requireActual('~/lib/utils/url_utility'),
+ getParameterByName: jest.fn(),
visitUrl: jest.fn(),
}));
@@ -84,9 +86,10 @@ describe('Filtered Search Manager', () => {
jest
.spyOn(FilteredSearchDropdownManager.prototype, 'updateDropdownOffset')
.mockImplementation();
- jest.spyOn(commonUtils, 'getParameterByName').mockReturnValue(null);
jest.spyOn(FilteredSearchVisualTokens, 'unselectTokens');
+ getParameterByName.mockReturnValue(null);
+
input = document.querySelector('.filtered-search');
tokensContainer = document.querySelector('.tokens-container');
manager = new FilteredSearchManager({ page, useDefaultState });
@@ -127,11 +130,10 @@ describe('Filtered Search Manager', () => {
jest
.spyOn(RecentSearchesService.prototype, 'fetch')
.mockImplementation(() => Promise.reject(new RecentSearchesServiceError()));
- jest.spyOn(window, 'Flash').mockImplementation();
manager.setup();
- expect(window.Flash).not.toHaveBeenCalled();
+ expect(createFlash).not.toHaveBeenCalled();
});
});
diff --git a/spec/frontend/filtered_search/visual_token_value_spec.js b/spec/frontend/filtered_search/visual_token_value_spec.js
index 772fa7d07ed..7185f382fc1 100644
--- a/spec/frontend/filtered_search/visual_token_value_spec.js
+++ b/spec/frontend/filtered_search/visual_token_value_spec.js
@@ -1,11 +1,14 @@
import { escape } from 'lodash';
import FilteredSearchSpecHelper from 'helpers/filtered_search_spec_helper';
import { TEST_HOST } from 'helpers/test_constants';
-import DropdownUtils from '~/filtered_search//dropdown_utils';
+import DropdownUtils from '~/filtered_search/dropdown_utils';
import VisualTokenValue from '~/filtered_search/visual_token_value';
+import createFlash from '~/flash';
import AjaxCache from '~/lib/utils/ajax_cache';
import UsersCache from '~/lib/utils/users_cache';
+jest.mock('~/flash');
+
describe('Filtered Search Visual Tokens', () => {
const findElements = (tokenElement) => {
const tokenNameElement = tokenElement.querySelector('.name');
@@ -43,7 +46,6 @@ describe('Filtered Search Visual Tokens', () => {
});
it('ignores error if UsersCache throws', (done) => {
- jest.spyOn(window, 'Flash').mockImplementation(() => {});
const dummyError = new Error('Earth rotated backwards');
const { subject, tokenValueContainer, tokenValueElement } = findElements(authorToken);
const tokenValue = tokenValueElement.innerText;
@@ -55,7 +57,7 @@ describe('Filtered Search Visual Tokens', () => {
subject
.updateUserTokenAppearance(tokenValueContainer, tokenValueElement, tokenValue)
.then(() => {
- expect(window.Flash.mock.calls.length).toBe(0);
+ expect(createFlash.mock.calls.length).toBe(0);
})
.then(done)
.catch(done.fail);