2017-01-10 18:02:20 -05:00
|
|
|
/* eslint-disable space-before-function-paren, no-unused-expressions, no-return-assign, no-param-reassign, no-var, new-cap, wrap-iife, no-unused-vars, quotes, jasmine/no-expect-in-setup-teardown, max-len */
|
2016-12-14 00:26:26 -05:00
|
|
|
/* global Project */
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-12-29 16:42:48 -05:00
|
|
|
require('select2/select2.js');
|
2017-01-09 18:23:54 -05:00
|
|
|
require('~/lib/utils/type_utility');
|
|
|
|
require('~/gl_dropdown');
|
|
|
|
require('~/api');
|
|
|
|
require('~/project_select');
|
|
|
|
require('~/project');
|
2016-07-24 16:45:11 -04:00
|
|
|
|
|
|
|
(function() {
|
|
|
|
describe('Project Title', function() {
|
2017-02-12 19:29:07 -05:00
|
|
|
preloadFixtures('issues/open-issue.html.raw');
|
2017-01-13 11:04:41 -05:00
|
|
|
loadJSONFixtures('projects.json');
|
|
|
|
|
2016-07-24 16:45:11 -04:00
|
|
|
beforeEach(function() {
|
2017-02-12 19:29:07 -05:00
|
|
|
loadFixtures('issues/open-issue.html.raw');
|
2017-01-30 16:02:19 -05:00
|
|
|
|
|
|
|
window.gon = {};
|
|
|
|
window.gon.api_version = 'v3';
|
|
|
|
|
2016-07-24 16:45:11 -04:00
|
|
|
return this.project = new Project();
|
|
|
|
});
|
2017-01-30 16:02:19 -05:00
|
|
|
|
|
|
|
describe('project list', function() {
|
2016-12-10 07:04:54 -05:00
|
|
|
var fakeAjaxResponse = function fakeAjaxResponse(req) {
|
|
|
|
var d;
|
|
|
|
expect(req.url).toBe('/api/v3/projects.json?simple=true');
|
2017-03-06 00:03:21 -05:00
|
|
|
expect(req.data).toEqual({ search: '', order_by: 'last_activity_at', per_page: 20, membership: true });
|
2016-12-10 07:04:54 -05:00
|
|
|
d = $.Deferred();
|
|
|
|
d.resolve(this.projects_data);
|
|
|
|
return d.promise();
|
|
|
|
};
|
|
|
|
|
2016-07-24 16:45:11 -04:00
|
|
|
beforeEach((function(_this) {
|
|
|
|
return function() {
|
2016-12-30 19:14:33 -05:00
|
|
|
_this.projects_data = getJSONFixture('projects.json');
|
2016-12-10 07:04:54 -05:00
|
|
|
return spyOn(jQuery, 'ajax').and.callFake(fakeAjaxResponse.bind(_this));
|
2016-07-24 16:45:11 -04:00
|
|
|
};
|
|
|
|
})(this));
|
2017-02-12 19:29:07 -05:00
|
|
|
it('toggles dropdown', function() {
|
|
|
|
var menu = $('.js-dropdown-menu-projects');
|
|
|
|
$('.js-projects-dropdown-toggle').click();
|
|
|
|
expect(menu).toHaveClass('open');
|
|
|
|
menu.find('.dropdown-menu-close-icon').click();
|
|
|
|
expect(menu).not.toHaveClass('open');
|
2016-07-24 16:45:11 -04:00
|
|
|
});
|
|
|
|
});
|
2017-01-30 16:02:19 -05:00
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
window.gon = {};
|
|
|
|
});
|
2016-07-24 16:45:11 -04:00
|
|
|
});
|
2017-02-10 02:29:41 -05:00
|
|
|
}).call(window);
|