gitlab-org--gitlab-foss/spec/javascripts/merge_request_spec.js

32 lines
1.3 KiB
JavaScript
Raw Normal View History

/* eslint-disable space-before-function-paren, no-return-assign */
/* global MergeRequest */
2016-07-24 16:45:11 -04:00
import '~/merge_request';
2016-07-24 16:45:11 -04:00
(function() {
describe('MergeRequest', function() {
return describe('task lists', function() {
preloadFixtures('merge_requests/merge_request_with_task_list.html.raw');
2016-07-24 16:45:11 -04:00
beforeEach(function() {
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();
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');
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');
});
});
});
}).call(window);