diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-10-24 22:48:55 +0100 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-10-24 22:48:55 +0100 |
commit | b5079721bfff6fd36d79da9c6ab22bfd9009f752 (patch) | |
tree | 6158103f11873217d007c59a72f06937454d415e /spec/javascripts/notes_spec.js | |
parent | 1ae013dad5cca881e54e4c67f42748ed6580bfec (diff) | |
download | gitlab-ce-b5079721bfff6fd36d79da9c6ab22bfd9009f752.tar.gz |
Add spec for root diff discussion note
Diffstat (limited to 'spec/javascripts/notes_spec.js')
-rw-r--r-- | spec/javascripts/notes_spec.js | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/spec/javascripts/notes_spec.js b/spec/javascripts/notes_spec.js index 2514f7ea841..8514c7ac5a1 100644 --- a/spec/javascripts/notes_spec.js +++ b/spec/javascripts/notes_spec.js @@ -362,13 +362,33 @@ import '~/notes'; $form.closest.and.returnValues(row, $form); $form.find.and.returnValues(discussionContainer); body.attr.and.returnValue(''); - - Notes.prototype.renderDiscussionNote.call(notes, note, $form); }); it('should call Notes.animateAppendNote', () => { + Notes.prototype.renderDiscussionNote.call(notes, note, $form); + expect(Notes.animateAppendNote).toHaveBeenCalledWith(note.discussion_html, $('.main-notes-list')); }); + + it('should append to row selected with line_code', () => { + $form.length = 0; + note.discussion_line_code = 'line_code'; + note.diff_discussion_html = '<tr></tr>'; + + const line = document.createElement('div'); + line.id = note.discussion_line_code; + document.body.appendChild(line); + + $form.closest.and.returnValues($form); + spyOn(document, 'getElementById').and.callThrough(); + spyOn($.fn, 'after').and.callThrough(); + + Notes.prototype.renderDiscussionNote.call(notes, note, $form); + + expect(document.getElementById).toHaveBeenCalledWith(note.discussion_line_code); + expect($.fn.after).toHaveBeenCalled(); + expect(line.nextSibling.outerHTML).toEqual(note.diff_discussion_html); + }); }); describe('Discussion sub note', () => { |