diff options
Diffstat (limited to 'spec/frontend/notes/components/noteable_note_spec.js')
-rw-r--r-- | spec/frontend/notes/components/noteable_note_spec.js | 71 |
1 files changed, 66 insertions, 5 deletions
diff --git a/spec/frontend/notes/components/noteable_note_spec.js b/spec/frontend/notes/components/noteable_note_spec.js index aa3eaa97e20..fc238feb974 100644 --- a/spec/frontend/notes/components/noteable_note_spec.js +++ b/spec/frontend/notes/components/noteable_note_spec.js @@ -34,7 +34,13 @@ describe('issue_note', () => { note, }, localVue, - stubs: ['note-header', 'user-avatar-link', 'note-actions', 'note-body'], + stubs: [ + 'note-header', + 'user-avatar-link', + 'note-actions', + 'note-body', + 'multiline-comment-form', + ], }); }); @@ -46,12 +52,30 @@ describe('issue_note', () => { it('should render if has multiline comment', () => { const position = { line_range: { - start_line_code: 'abc_1_1', - end_line_code: 'abc_2_2', + start: { + line_code: 'abc_1_1', + type: null, + old_line: '1', + new_line: '1', + }, + end: { + line_code: 'abc_2_2', + type: null, + old_line: '2', + new_line: '2', + }, }, }; + const line = { + line_code: 'abc_1_1', + type: null, + old_line: '1', + new_line: '1', + }; wrapper.setProps({ note: { ...note, position }, + discussionRoot: true, + line, }); return wrapper.vm.$nextTick().then(() => { @@ -59,15 +83,51 @@ describe('issue_note', () => { }); }); + it('should render multiline comment if editing discussion root', () => { + wrapper.setProps({ discussionRoot: true }); + wrapper.vm.isEditing = true; + + return wrapper.vm.$nextTick().then(() => { + expect(findMultilineComment().exists()).toBe(true); + }); + }); + + it('should not render multiline comment form unless it is the discussion root', () => { + wrapper.setProps({ discussionRoot: false }); + wrapper.vm.isEditing = true; + + return wrapper.vm.$nextTick().then(() => { + expect(findMultilineComment().exists()).toBe(false); + }); + }); + it('should not render if has single line comment', () => { const position = { line_range: { - start_line_code: 'abc_1_1', - end_line_code: 'abc_1_1', + start: { + line_code: 'abc_1_1', + type: null, + old_line: '1', + new_line: '1', + }, + end: { + line_code: 'abc_1_1', + type: null, + old_line: '1', + new_line: '1', + }, }, }; + const line = { + line_code: 'abc_1_1', + type: null, + old_line: '1', + new_line: '1', + }; wrapper.setProps({ note: { ...note, position }, + discussionRoot: true, + line, }); return wrapper.vm.$nextTick().then(() => { @@ -139,6 +199,7 @@ describe('issue_note', () => { store.hotUpdate({ actions: { updateNote() {}, + setSelectedCommentPositionHover() {}, }, }); const noteBodyComponent = wrapper.find(NoteBody); |