diff options
author | Phil Hughes <me@iamphill.com> | 2018-09-17 10:49:41 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-09-17 10:49:41 +0100 |
commit | c48f0c1aed8f6a0db43afb27ad5f3cc13f09dedc (patch) | |
tree | d20f93723fb1cbab161a42aa1dcf90a53e04d112 /spec | |
parent | 5c39c7c3b919126f3b052da407cd29aa3167b40e (diff) | |
download | gitlab-ce-c48f0c1aed8f6a0db43afb27ad5f3cc13f09dedc.tar.gz |
Added specs to isDiscussionApplicableToLine
It now tests for the latest diff check
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/diffs/store/utils_spec.js | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/spec/javascripts/diffs/store/utils_spec.js b/spec/javascripts/diffs/store/utils_spec.js index fd740c5e798..cb712463e12 100644 --- a/spec/javascripts/diffs/store/utils_spec.js +++ b/spec/javascripts/diffs/store/utils_spec.js @@ -350,13 +350,13 @@ describe('DiffsStoreUtils', () => { it('returns true when the discussion is up to date', () => { expect( - utils.isDiscussionApplicableToLine(discussions.upToDateDiscussion1, diffPosition), + utils.isDiscussionApplicableToLine(discussions.upToDateDiscussion1, diffPosition, true), ).toBe(true); }); it('returns false when the discussion is not up to date', () => { expect( - utils.isDiscussionApplicableToLine(discussions.outDatedDiscussion1, diffPosition), + utils.isDiscussionApplicableToLine(discussions.outDatedDiscussion1, diffPosition, true), ).toBe(false); }); @@ -366,10 +366,14 @@ describe('DiffsStoreUtils', () => { delete discussion.position; expect( - utils.isDiscussionApplicableToLine(discussion, { - ...diffPosition, - lineCode: 'ABC_1', - }), + utils.isDiscussionApplicableToLine( + discussion, + { + ...diffPosition, + lineCode: 'ABC_1', + }, + true, + ), ).toBe(false); }); @@ -379,11 +383,32 @@ describe('DiffsStoreUtils', () => { delete discussion.position; expect( - utils.isDiscussionApplicableToLine(discussion, { - ...diffPosition, - lineCode: 'ABC_1', - }), + utils.isDiscussionApplicableToLine( + discussion, + { + ...diffPosition, + lineCode: 'ABC_1', + }, + true, + ), ).toBe(true); }); + + it('returns false when not latest diff', () => { + const discussion = { ...discussions.outDatedDiscussion1, line_code: 'ABC_1', active: true }; + delete discussion.original_position; + delete discussion.position; + + expect( + utils.isDiscussionApplicableToLine( + discussion, + { + ...diffPosition, + lineCode: 'ABC_1', + }, + false, + ), + ).toBe(false); + }); }); }); |