summaryrefslogtreecommitdiff
path: root/spec/javascripts/notes_spec.js
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-09-20 14:48:13 +0530
committerTimothy Andrew <mail@timothyandrew.net>2016-09-20 14:48:13 +0530
commitfa890604aaf15b9e4f0199e6a4cff24c29955a37 (patch)
tree1606c5585a93d3c0449effbe7b5cc901900833dd /spec/javascripts/notes_spec.js
parent0b97b42d60a662c0d138c44f6dbd05a3048ac349 (diff)
parent95b9421ad3b2678da6e0af0131eafd52cdd0b2a5 (diff)
downloadgitlab-ce-fa890604aaf15b9e4f0199e6a4cff24c29955a37.tar.gz
Merge remote-tracking branch 'origin/master' into 21170-cycle-analytics
Diffstat (limited to 'spec/javascripts/notes_spec.js')
-rw-r--r--spec/javascripts/notes_spec.js57
1 files changed, 45 insertions, 12 deletions
diff --git a/spec/javascripts/notes_spec.js b/spec/javascripts/notes_spec.js
index 14dc6bfdfde..a588f403dd5 100644
--- a/spec/javascripts/notes_spec.js
+++ b/spec/javascripts/notes_spec.js
@@ -1,8 +1,7 @@
-
/*= require notes */
-
-
+/*= require autosize */
/*= require gl_form */
+/*= require lib/utils/text_utility */
(function() {
window.gon || (window.gon = {});
@@ -12,29 +11,63 @@
};
describe('Notes', function() {
- return describe('task lists', function() {
+ describe('task lists', function() {
fixture.preload('issue_note.html');
+
beforeEach(function() {
fixture.load('issue_note.html');
$('form').on('submit', function(e) {
- return e.preventDefault();
+ e.preventDefault();
});
- return this.notes = new Notes();
+ this.notes = new Notes();
});
+
it('modifies the Markdown field', function() {
$('input[type=checkbox]').attr('checked', true).trigger('change');
- return expect($('.js-task-list-field').val()).toBe('- [x] Task List Item');
+ expect($('.js-task-list-field').val()).toBe('- [x] Task List Item');
});
- return it('submits the form on tasklist:changed', function() {
- var submitted;
- submitted = false;
+
+ it('submits the form on tasklist:changed', function() {
+ var submitted = false;
$('form').on('submit', function(e) {
submitted = true;
- return e.preventDefault();
+ e.preventDefault();
});
+
$('.js-task-list-field').trigger('tasklist:changed');
- return expect(submitted).toBe(true);
+ 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');
+ });
});
+
+ 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();
+ })
});
});