From b5079721bfff6fd36d79da9c6ab22bfd9009f752 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Tue, 24 Oct 2017 22:48:55 +0100 Subject: Add spec for root diff discussion note --- spec/javascripts/notes_spec.js | 24 ++++++++++++++++++++++-- 1 file 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 = ''; + + 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', () => { -- cgit v1.2.1