diff options
author | Kushal Pandya <kushalspandya@gmail.com> | 2017-05-18 18:05:01 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-05-18 18:05:01 +0000 |
commit | 4b9c952d358b55aecd19fa3c3c6cedc91d823bba (patch) | |
tree | d8367e578fc2837533ad816ee911f20dc3cacf99 /spec | |
parent | 6ca5a9890c2a6761c932a6da4e82505db4b756f5 (diff) | |
download | gitlab-ce-4b9c952d358b55aecd19fa3c3c6cedc91d823bba.tar.gz |
Fix ability to edit diff notes multiple times
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/notes_spec.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/javascripts/notes_spec.js b/spec/javascripts/notes_spec.js index 7f12dea5277..d3494aaa94f 100644 --- a/spec/javascripts/notes_spec.js +++ b/spec/javascripts/notes_spec.js @@ -79,6 +79,47 @@ import '~/notes'; }); }); + describe('updateNote', () => { + let sampleComment; + let noteEntity; + let $form; + let $notesContainer; + + beforeEach(() => { + this.notes = new Notes('', []); + window.gon.current_username = 'root'; + window.gon.current_user_fullname = 'Administrator'; + sampleComment = 'foo'; + noteEntity = { + id: 1234, + html: `<li class="note note-row-1234 timeline-entry" id="note_1234"> + <div class="note-text">${sampleComment}</div> + </li>`, + note: sampleComment, + valid: true + }; + $form = $('form.js-main-target-form'); + $notesContainer = $('ul.main-notes-list'); + $form.find('textarea.js-note-text').val(sampleComment); + }); + + it('updates note and resets edit form', () => { + const deferred = $.Deferred(); + spyOn($, 'ajax').and.returnValue(deferred.promise()); + spyOn(this.notes, 'revertNoteEditForm'); + + $('.js-comment-button').click(); + deferred.resolve(noteEntity); + + const $targetNote = $notesContainer.find(`#note_${noteEntity.id}`); + const updatedNote = Object.assign({}, noteEntity); + updatedNote.note = 'bar'; + this.notes.updateNote(updatedNote, $targetNote); + + expect(this.notes.revertNoteEditForm).toHaveBeenCalledWith($targetNote); + }); + }); + describe('renderNote', () => { let notes; let note; |