Add spec for root diff discussion note

This commit is contained in:
Luke "Jared" Bennett 2017-10-24 22:48:55 +01:00
parent 1ae013dad5
commit b5079721bf
No known key found for this signature in database
GPG Key ID: 402ED51FB5D306C2
1 changed files with 22 additions and 2 deletions

View File

@ -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', () => {