2016-09-13 17:45:13 +05:30
|
|
|
/*= require notes */
|
2016-09-29 09:46:39 +05:30
|
|
|
/*= require autosize */
|
2016-09-13 17:45:13 +05:30
|
|
|
/*= require gl_form */
|
2016-09-29 09:46:39 +05:30
|
|
|
/*= require lib/utils/text_utility */
|
2016-09-13 17:45:13 +05:30
|
|
|
|
|
|
|
(function() {
|
|
|
|
window.gon || (window.gon = {});
|
|
|
|
|
|
|
|
window.disableButtonIfEmptyField = function() {
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('Notes', function() {
|
2016-09-29 09:46:39 +05:30
|
|
|
describe('task lists', function() {
|
2016-09-13 17:45:13 +05:30
|
|
|
fixture.preload('issue_note.html');
|
2016-09-29 09:46:39 +05:30
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
beforeEach(function() {
|
|
|
|
fixture.load('issue_note.html');
|
|
|
|
$('form').on('submit', function(e) {
|
2016-09-29 09:46:39 +05:30
|
|
|
e.preventDefault();
|
2016-09-13 17:45:13 +05:30
|
|
|
});
|
2016-09-29 09:46:39 +05:30
|
|
|
this.notes = new Notes();
|
2016-09-13 17:45:13 +05:30
|
|
|
});
|
2016-09-29 09:46:39 +05:30
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
it('modifies the Markdown field', function() {
|
|
|
|
$('input[type=checkbox]').attr('checked', true).trigger('change');
|
2016-09-29 09:46:39 +05:30
|
|
|
expect($('.js-task-list-field').val()).toBe('- [x] Task List Item');
|
2016-09-13 17:45:13 +05:30
|
|
|
});
|
2016-09-29 09:46:39 +05:30
|
|
|
|
|
|
|
it('submits the form on tasklist:changed', function() {
|
|
|
|
var submitted = false;
|
2016-09-13 17:45:13 +05:30
|
|
|
$('form').on('submit', function(e) {
|
|
|
|
submitted = true;
|
2016-09-29 09:46:39 +05:30
|
|
|
e.preventDefault();
|
2016-09-13 17:45:13 +05:30
|
|
|
});
|
2016-09-29 09:46:39 +05:30
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
$('.js-task-list-field').trigger('tasklist:changed');
|
2016-09-29 09:46:39 +05:30
|
|
|
expect(submitted).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('comments', function() {
|
|
|
|
var commentsTemplate = 'comments.html';
|
|
|
|
var textarea = '.js-note-text';
|
|
|
|
fixture.preload(commentsTemplate);
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
fixture.load(commentsTemplate);
|
|
|
|
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-09-13 17:45:13 +05:30
|
|
|
});
|
2016-09-29 09:46:39 +05:30
|
|
|
|
|
|
|
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-09-13 17:45:13 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}).call(this);
|