2016-12-14 00:26:26 -05:00
|
|
|
/* global Project */
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-05-16 17:57:05 -04:00
|
|
|
import 'select2/select2';
|
2017-05-16 17:01:51 -04:00
|
|
|
import '~/gl_dropdown';
|
|
|
|
import '~/api';
|
|
|
|
import '~/project_select';
|
|
|
|
import '~/project';
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-06-16 16:40:28 -04:00
|
|
|
describe('Project Title', () => {
|
|
|
|
preloadFixtures('issues/open-issue.html.raw');
|
|
|
|
loadJSONFixtures('projects.json');
|
2017-01-13 11:04:41 -05:00
|
|
|
|
2017-06-16 16:40:28 -04:00
|
|
|
beforeEach(() => {
|
|
|
|
loadFixtures('issues/open-issue.html.raw');
|
2017-01-30 16:02:19 -05:00
|
|
|
|
2017-06-16 16:40:28 -04:00
|
|
|
window.gon = {};
|
|
|
|
window.gon.api_version = 'v3';
|
2017-01-30 16:02:19 -05:00
|
|
|
|
2017-06-16 16:40:28 -04:00
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Project();
|
|
|
|
});
|
2017-01-30 16:02:19 -05:00
|
|
|
|
2017-06-16 16:40:28 -04:00
|
|
|
describe('project list', () => {
|
|
|
|
let reqUrl;
|
|
|
|
let reqData;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
const fakeResponseData = getJSONFixture('projects.json');
|
|
|
|
spyOn(jQuery, 'ajax').and.callFake((req) => {
|
|
|
|
const def = $.Deferred();
|
|
|
|
reqUrl = req.url;
|
|
|
|
reqData = req.data;
|
|
|
|
def.resolve(fakeResponseData);
|
|
|
|
return def.promise();
|
2016-07-24 16:45:11 -04:00
|
|
|
});
|
|
|
|
});
|
2017-01-30 16:02:19 -05:00
|
|
|
|
2017-06-16 16:40:28 -04:00
|
|
|
it('toggles dropdown', () => {
|
|
|
|
const $menu = $('.js-dropdown-menu-projects');
|
|
|
|
$('.js-projects-dropdown-toggle').click();
|
|
|
|
expect($menu).toHaveClass('open');
|
|
|
|
expect(reqUrl).toBe('/api/v3/projects.json?simple=true');
|
|
|
|
expect(reqData).toEqual({
|
|
|
|
search: '',
|
|
|
|
order_by: 'last_activity_at',
|
|
|
|
per_page: 20,
|
|
|
|
membership: true,
|
|
|
|
});
|
|
|
|
$menu.find('.dropdown-menu-close-icon').click();
|
|
|
|
expect($menu).not.toHaveClass('open');
|
2017-01-30 16:02:19 -05:00
|
|
|
});
|
2016-07-24 16:45:11 -04:00
|
|
|
});
|
2017-06-16 16:40:28 -04:00
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
window.gon = {};
|
|
|
|
});
|
|
|
|
});
|