69e4072f89
* master: (389 commits)
Document "No gems fetched from git repositories" policy [ci skip]
Typos
Small gramatical tweaks
Typos
Added PHP & NPM doc
Use `:empty_project` where possible in request specs
Add caching of droplab ajax requests
Use `:empty_project` where possible in model specs
Revert 3f17f29a
Remove unused js response from refs controller
Add MR id to changelog entry
fixed small mini pipeline graph line glitch
Prevent form to be submitted twice
Fix Error 500 when repositories contain annotated tags pointing to blobs
Fix /explore sorting (trending)
Simplify wording in "adding an image" docs
Remove "official merge window" from CONTRIBUTING.md [ci skip]
Update repository check documentation
Fixed flexbox and wrap issues
Update two_factor_authentication.md
...
78 lines
2.3 KiB
JavaScript
78 lines
2.3 KiB
JavaScript
/* eslint-disable space-before-function-paren, no-unused-expressions, no-var, object-shorthand, comma-dangle, max-len */
|
|
/* global Notes */
|
|
|
|
require('~/notes');
|
|
require('vendor/autosize');
|
|
require('~/gl_form');
|
|
require('~/lib/utils/text_utility');
|
|
|
|
(function() {
|
|
window.gon || (window.gon = {});
|
|
window.gl = window.gl || {};
|
|
gl.utils = gl.utils || {};
|
|
|
|
describe('Notes', function() {
|
|
var commentsTemplate = 'issues/issue_with_comment.html.raw';
|
|
preloadFixtures(commentsTemplate);
|
|
|
|
beforeEach(function () {
|
|
loadFixtures(commentsTemplate);
|
|
gl.utils.disableButtonIfEmptyField = _.noop;
|
|
window.project_uploads_path = 'http://test.host/uploads';
|
|
$('body').data('page', 'projects:issues:show');
|
|
});
|
|
|
|
describe('task lists', function() {
|
|
beforeEach(function() {
|
|
$('form').on('submit', function(e) {
|
|
e.preventDefault();
|
|
});
|
|
this.notes = new Notes();
|
|
});
|
|
|
|
it('modifies the Markdown field', function() {
|
|
$('input[type=checkbox]').attr('checked', true).trigger('change');
|
|
expect($('.js-task-list-field').val()).toBe('- [x] Task List Item');
|
|
});
|
|
|
|
it('submits the form on tasklist:changed', function() {
|
|
var submitted = false;
|
|
$('form').on('submit', function(e) {
|
|
submitted = true;
|
|
e.preventDefault();
|
|
});
|
|
|
|
$('.js-task-list-field').trigger('tasklist:changed');
|
|
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');
|
|
});
|
|
});
|
|
|
|
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();
|
|
});
|
|
});
|
|
});
|
|
}).call(this);
|