diff options
Diffstat (limited to 'spec')
3 files changed, 103 insertions, 3 deletions
diff --git a/spec/javascripts/diffs/components/diff_line_gutter_content_spec.js b/spec/javascripts/diffs/components/diff_line_gutter_content_spec.js index 2d136a63c52..a1a37b342b7 100644 --- a/spec/javascripts/diffs/components/diff_line_gutter_content_spec.js +++ b/spec/javascripts/diffs/components/diff_line_gutter_content_spec.js @@ -48,7 +48,11 @@ describe('DiffLineGutterContent', () => { it('should return discussions for the given lineCode', () => { const { lineCode } = getDiffFileMock().highlightedDiffLines[1]; - const component = createComponent({ lineCode, showCommentButton: true }); + const component = createComponent({ + lineCode, + showCommentButton: true, + discussions: getDiscussionsMockData(), + }); setDiscussions(component); diff --git a/spec/javascripts/diffs/store/getters_spec.js b/spec/javascripts/diffs/store/getters_spec.js index 7706c32d24d..a59b26b2634 100644 --- a/spec/javascripts/diffs/store/getters_spec.js +++ b/spec/javascripts/diffs/store/getters_spec.js @@ -184,6 +184,104 @@ describe('Diffs Module Getters', () => { }); }); + describe('singleDiscussionByLineCode', () => { + it('returns found discussion per line Code', () => { + const discussionsMock = {}; + discussionsMock.ABC = discussionMock; + + expect( + getters.singleDiscussionByLineCode(localState, {}, null, { + discussionsByLineCode: () => discussionsMock, + })('DEF'), + ).toEqual([]); + }); + + it('returns empty array when no discussions match', () => { + expect( + getters.singleDiscussionByLineCode(localState, {}, null, { + discussionsByLineCode: () => {}, + })('DEF'), + ).toEqual([]); + }); + }); + + describe('shouldRenderParallelCommentRow', () => { + let line; + + beforeEach(() => { + line = {}; + + line.left = { + lineCode: 'ABC', + }; + + line.right = { + lineCode: 'DEF', + }; + }); + + it('returns true when discussion is expanded', () => { + discussionMock.expanded = true; + + expect( + getters.shouldRenderParallelCommentRow(localState, { + singleDiscussionByLineCode: () => [discussionMock], + })(line), + ).toEqual(true); + }); + + it('returns false when no discussion was found', () => { + localState.diffLineCommentForms.ABC = false; + localState.diffLineCommentForms.DEF = false; + + expect( + getters.shouldRenderParallelCommentRow(localState, { + singleDiscussionByLineCode: () => [], + })(line), + ).toEqual(false); + }); + + it('returns true when discussionForm was found', () => { + localState.diffLineCommentForms.ABC = {}; + + expect( + getters.shouldRenderParallelCommentRow(localState, { + singleDiscussionByLineCode: () => [discussionMock], + })(line), + ).toEqual(true); + }); + }); + + describe('shouldRenderInlineCommentRow', () => { + it('returns true when diffLineCommentForms has form', () => { + localState.diffLineCommentForms.ABC = {}; + + expect( + getters.shouldRenderInlineCommentRow(localState)({ + lineCode: 'ABC', + }), + ).toEqual(true); + }); + + it('returns false when no line discussions were found', () => { + expect( + getters.shouldRenderInlineCommentRow(localState, { + singleDiscussionByLineCode: () => [], + })('DEF'), + ).toEqual(false); + }); + + it('returns true if all found discussions are expanded', () => { + discussionMock.expanded = true; + + expect( + getters.shouldRenderInlineCommentRow(localState, { + singleDiscussionByLineCode: () => [discussionMock], + })('ABC'), + ).toEqual(true); + }); + }); + describe('getDiffFileDiscussions', () => { it('returns an array with discussions when fileHash matches and the discussion belongs to a diff', () => { discussionMock.diff_file.file_hash = diffFileMock.fileHash; diff --git a/spec/javascripts/vue_shared/components/diff_viewer/viewers/image_diff_viewer_spec.js b/spec/javascripts/vue_shared/components/diff_viewer/viewers/image_diff_viewer_spec.js index b878286ae3f..dde49b4a5d7 100644 --- a/spec/javascripts/vue_shared/components/diff_viewer/viewers/image_diff_viewer_spec.js +++ b/spec/javascripts/vue_shared/components/diff_viewer/viewers/image_diff_viewer_spec.js @@ -170,8 +170,6 @@ describe('ImageDiffViewer', () => { vm.$el.querySelector('.view-modes-menu li:nth-child(3)').click(); vm.$nextTick(() => { - expect(vm.$el.querySelector('.dragger').style.left).toBe('100px'); - dragSlider(vm.$el.querySelector('.dragger')); vm.$nextTick(() => { |