2017-01-10 18:02:20 -05:00
|
|
|
/* eslint-disable space-before-function-paren, no-return-assign */
|
2016-12-14 00:26:26 -05:00
|
|
|
/* global MergeRequest */
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-05-16 17:01:51 -04:00
|
|
|
import '~/merge_request';
|
2017-06-08 12:15:34 -04:00
|
|
|
import CloseReopenReportToggle from '~/close_reopen_report_toggle';
|
2017-07-07 11:04:43 -04:00
|
|
|
import IssuablesHelper from '~/helpers/issuables_helper';
|
2016-07-24 16:45:11 -04:00
|
|
|
|
|
|
|
(function() {
|
|
|
|
describe('MergeRequest', function() {
|
2017-06-07 15:34:19 -04:00
|
|
|
describe('task lists', function() {
|
2017-02-13 21:52:20 -05:00
|
|
|
preloadFixtures('merge_requests/merge_request_with_task_list.html.raw');
|
2016-07-24 16:45:11 -04:00
|
|
|
beforeEach(function() {
|
2017-02-13 21:52:20 -05:00
|
|
|
loadFixtures('merge_requests/merge_request_with_task_list.html.raw');
|
2016-07-24 16:45:11 -04:00
|
|
|
return this.merge = new MergeRequest();
|
|
|
|
});
|
|
|
|
it('modifies the Markdown field', function() {
|
|
|
|
spyOn(jQuery, 'ajax').and.stub();
|
2017-05-19 08:03:41 -04:00
|
|
|
const changeEvent = document.createEvent('HTMLEvents');
|
|
|
|
changeEvent.initEvent('change', true, true);
|
|
|
|
$('input[type=checkbox]').attr('checked', true)[0].dispatchEvent(changeEvent);
|
2016-07-24 16:45:11 -04:00
|
|
|
return expect($('.js-task-list-field').val()).toBe('- [x] Task List Item');
|
|
|
|
});
|
|
|
|
return it('submits an ajax request on tasklist:changed', function() {
|
|
|
|
spyOn(jQuery, 'ajax').and.callFake(function(req) {
|
|
|
|
expect(req.type).toBe('PATCH');
|
2017-02-13 21:52:20 -05:00
|
|
|
expect(req.url).toBe(`${gl.TEST_HOST}/frontend-fixtures/merge-requests-project/merge_requests/1.json`);
|
2016-07-24 16:45:11 -04:00
|
|
|
return expect(req.data.merge_request.description).not.toBe(null);
|
|
|
|
});
|
|
|
|
return $('.js-task-list-field').trigger('tasklist:changed');
|
|
|
|
});
|
|
|
|
});
|
2017-06-07 15:34:19 -04:00
|
|
|
|
|
|
|
describe('class constructor', () => {
|
|
|
|
it('calls .initCloseReopenReport', () => {
|
2017-07-07 11:04:43 -04:00
|
|
|
spyOn(IssuablesHelper, 'initCloseReopenReport');
|
2017-06-07 15:34:19 -04:00
|
|
|
|
2017-07-07 11:04:43 -04:00
|
|
|
new MergeRequest(); // eslint-disable-line no-new
|
2017-06-07 15:34:19 -04:00
|
|
|
|
2017-07-07 11:04:43 -04:00
|
|
|
expect(IssuablesHelper.initCloseReopenReport).toHaveBeenCalled();
|
2017-06-07 15:34:19 -04:00
|
|
|
});
|
|
|
|
|
2017-06-08 12:15:34 -04:00
|
|
|
it('calls .initDroplab', () => {
|
2017-06-07 15:34:19 -04:00
|
|
|
const container = jasmine.createSpyObj('container', ['querySelector']);
|
|
|
|
const dropdownTrigger = {};
|
|
|
|
const dropdownList = {};
|
|
|
|
const button = {};
|
|
|
|
|
2017-06-08 12:15:34 -04:00
|
|
|
spyOn(CloseReopenReportToggle.prototype, 'initDroplab');
|
2017-06-07 15:34:19 -04:00
|
|
|
spyOn(document, 'querySelector').and.returnValue(container);
|
|
|
|
container.querySelector.and.returnValues(dropdownTrigger, dropdownList, button);
|
|
|
|
|
2017-07-07 11:04:43 -04:00
|
|
|
new MergeRequest(); // eslint-disable-line no-new
|
2017-06-07 15:34:19 -04:00
|
|
|
|
|
|
|
expect(document.querySelector).toHaveBeenCalledWith('.js-issuable-close-dropdown');
|
|
|
|
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-toggle');
|
|
|
|
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-menu');
|
|
|
|
expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-button');
|
2017-06-08 12:15:34 -04:00
|
|
|
expect(CloseReopenReportToggle.prototype.initDroplab).toHaveBeenCalled();
|
2017-06-07 15:34:19 -04:00
|
|
|
});
|
|
|
|
});
|
2016-07-24 16:45:11 -04:00
|
|
|
});
|
2017-02-10 02:29:41 -05:00
|
|
|
}).call(window);
|