gitlab-org--gitlab-foss/spec/javascripts/search_spec.js
Winnie Hellmann ad985a7a28 Merge branch 'winh-remove-sushi' into 'master'
Remove .raw from JavaScript fixture file names

Closes #59201

See merge request gitlab-org/gitlab-ce!26430

(cherry picked from commit 79a45f7f02)
2019-03-26 16:03:28 +00:00

41 lines
1.2 KiB
JavaScript

import $ from 'jquery';
import Api from '~/api';
import Search from '~/pages/search/show/search';
describe('Search', () => {
const fixturePath = 'search/show.html';
const searchTerm = 'some search';
const fillDropdownInput = dropdownSelector => {
const dropdownElement = document.querySelector(dropdownSelector).parentNode;
const inputElement = dropdownElement.querySelector('.dropdown-input-field');
inputElement.value = searchTerm;
return inputElement;
};
preloadFixtures(fixturePath);
beforeEach(() => {
loadFixtures(fixturePath);
new Search(); // eslint-disable-line no-new
});
it('requests groups from backend when filtering', done => {
spyOn(Api, 'groups').and.callFake(term => {
expect(term).toBe(searchTerm);
done();
});
const inputElement = fillDropdownInput('.js-search-group-dropdown');
$(inputElement).trigger('input');
});
it('requests projects from backend when filtering', done => {
spyOn(Api, 'projects').and.callFake(term => {
expect(term).toBe(searchTerm);
done();
});
const inputElement = fillDropdownInput('.js-search-project-dropdown');
$(inputElement).trigger('input');
});
});