2016-12-14 05:26:26 +00:00
|
|
|
/* eslint-disable space-before-function-paren, no-unused-expressions, no-var, object-shorthand, comma-dangle, semi, padded-blocks, max-len */
|
|
|
|
/* global Notes */
|
|
|
|
|
2016-12-29 21:42:48 +00:00
|
|
|
require('notes');
|
|
|
|
require('vendor/autosize');
|
|
|
|
require('gl_form');
|
|
|
|
require('lib/utils/text_utility');
|
2016-07-24 20:45:11 +00:00
|
|
|
|
|
|
|
(function() {
|
|
|
|
window.gon || (window.gon = {});
|
2016-11-22 22:46:58 +00:00
|
|
|
window.gl = window.gl || {};
|
|
|
|
gl.utils = gl.utils || {};
|
2016-07-24 20:45:11 +00:00
|
|
|
|
|
|
|
describe('Notes', function() {
|
2016-12-30 21:27:40 +00:00
|
|
|
var commentsTemplate = 'issues/issue_with_comment.html.raw';
|
2016-12-31 00:14:33 +00:00
|
|
|
preloadFixtures(commentsTemplate);
|
2016-08-31 14:32:48 +00:00
|
|
|
|
2016-11-22 22:46:58 +00:00
|
|
|
beforeEach(function () {
|
2016-12-31 00:14:33 +00:00
|
|
|
loadFixtures(commentsTemplate);
|
2016-11-22 22:46:58 +00:00
|
|
|
gl.utils.disableButtonIfEmptyField = _.noop;
|
|
|
|
window.project_uploads_path = 'http://test.host/uploads';
|
2016-12-08 21:49:32 +00:00
|
|
|
$('body').data('page', 'projects:issues:show');
|
2016-11-22 22:46:58 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('task lists', function() {
|
2016-07-24 20:45:11 +00:00
|
|
|
beforeEach(function() {
|
|
|
|
$('form').on('submit', function(e) {
|
2016-08-31 14:32:48 +00:00
|
|
|
e.preventDefault();
|
2016-07-24 20:45:11 +00:00
|
|
|
});
|
2016-08-31 14:32:48 +00:00
|
|
|
this.notes = new Notes();
|
2016-07-24 20:45:11 +00:00
|
|
|
});
|
2016-08-31 14:32:48 +00:00
|
|
|
|
2016-07-24 20:45:11 +00:00
|
|
|
it('modifies the Markdown field', function() {
|
|
|
|
$('input[type=checkbox]').attr('checked', true).trigger('change');
|
2016-08-31 14:32:48 +00:00
|
|
|
expect($('.js-task-list-field').val()).toBe('- [x] Task List Item');
|
2016-07-24 20:45:11 +00:00
|
|
|
});
|
2016-08-31 14:32:48 +00:00
|
|
|
|
|
|
|
it('submits the form on tasklist:changed', function() {
|
|
|
|
var submitted = false;
|
2016-07-24 20:45:11 +00:00
|
|
|
$('form').on('submit', function(e) {
|
|
|
|
submitted = true;
|
2016-08-31 14:32:48 +00:00
|
|
|
e.preventDefault();
|
2016-07-24 20:45:11 +00:00
|
|
|
});
|
2016-08-31 14:32:48 +00:00
|
|
|
|
2016-07-24 20:45:11 +00:00
|
|
|
$('.js-task-list-field').trigger('tasklist:changed');
|
2016-08-31 14:32:48 +00:00
|
|
|
expect(submitted).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('comments', function() {
|
|
|
|
var textarea = '.js-note-text';
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
this.notes = new Notes();
|
|
|
|
|
|
|
|
this.autoSizeSpy = spyOnEvent($(textarea), 'autosize:update');
|
|
|
|
spyOn(this.notes, 'renderNote').and.stub();
|
|
|
|
|
|
|
|
$(textarea).data('autosave', {
|
|
|
|
reset: function() {}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('form').on('submit', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
$('.js-main-target-form').trigger('ajax:success');
|
|
|
|
});
|
2016-07-24 20:45:11 +00:00
|
|
|
});
|
2016-08-31 14:32:48 +00:00
|
|
|
|
|
|
|
it('autosizes after comment submission', function() {
|
|
|
|
$(textarea).text('This is an example comment note');
|
|
|
|
expect(this.autoSizeSpy).not.toHaveBeenTriggered();
|
|
|
|
|
|
|
|
$('.js-comment-button').click();
|
|
|
|
expect(this.autoSizeSpy).toHaveBeenTriggered();
|
|
|
|
})
|
2016-07-24 20:45:11 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}).call(this);
|