Changed isDiscussionApplicableToLine to accept an object
This commit is contained in:
parent
c48f0c1aed
commit
90673dbcb8
3 changed files with 28 additions and 16 deletions
|
@ -97,7 +97,11 @@ export default {
|
|||
isDiffDiscussion &&
|
||||
hasLineCode &&
|
||||
diffPosition &&
|
||||
isDiscussionApplicableToLine(firstDiscussion, diffPosition, state.latestDiff)
|
||||
isDiscussionApplicableToLine({
|
||||
discussion: firstDiscussion,
|
||||
diffPosition,
|
||||
latestDiff: state.latestDiff,
|
||||
})
|
||||
) {
|
||||
const targetLine = selectedFile.parallelDiffLines.find(
|
||||
line =>
|
||||
|
|
|
@ -254,7 +254,7 @@ export function getDiffPositionByLineCode(diffFiles) {
|
|||
|
||||
// This method will check whether the discussion is still applicable
|
||||
// to the diff line in question regarding different versions of the MR
|
||||
export function isDiscussionApplicableToLine(discussion, diffPosition, latestDiff) {
|
||||
export function isDiscussionApplicableToLine({ discussion, diffPosition, latestDiff }) {
|
||||
const { lineCode, ...diffPositionCopy } = diffPosition;
|
||||
|
||||
if (discussion.original_position && discussion.position) {
|
||||
|
|
|
@ -350,13 +350,21 @@ describe('DiffsStoreUtils', () => {
|
|||
|
||||
it('returns true when the discussion is up to date', () => {
|
||||
expect(
|
||||
utils.isDiscussionApplicableToLine(discussions.upToDateDiscussion1, diffPosition, true),
|
||||
utils.isDiscussionApplicableToLine({
|
||||
discussion: discussions.upToDateDiscussion1,
|
||||
diffPosition,
|
||||
latestDiff: true,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when the discussion is not up to date', () => {
|
||||
expect(
|
||||
utils.isDiscussionApplicableToLine(discussions.outDatedDiscussion1, diffPosition, true),
|
||||
utils.isDiscussionApplicableToLine({
|
||||
discussion: discussions.outDatedDiscussion1,
|
||||
diffPosition,
|
||||
latestDiff: true,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
|
@ -366,14 +374,14 @@ describe('DiffsStoreUtils', () => {
|
|||
delete discussion.position;
|
||||
|
||||
expect(
|
||||
utils.isDiscussionApplicableToLine(
|
||||
utils.isDiscussionApplicableToLine({
|
||||
discussion,
|
||||
{
|
||||
diffPosition: {
|
||||
...diffPosition,
|
||||
lineCode: 'ABC_1',
|
||||
},
|
||||
true,
|
||||
),
|
||||
latestDiff: true,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
|
@ -383,14 +391,14 @@ describe('DiffsStoreUtils', () => {
|
|||
delete discussion.position;
|
||||
|
||||
expect(
|
||||
utils.isDiscussionApplicableToLine(
|
||||
utils.isDiscussionApplicableToLine({
|
||||
discussion,
|
||||
{
|
||||
diffPosition: {
|
||||
...diffPosition,
|
||||
lineCode: 'ABC_1',
|
||||
},
|
||||
true,
|
||||
),
|
||||
latestDiff: true,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
|
@ -400,14 +408,14 @@ describe('DiffsStoreUtils', () => {
|
|||
delete discussion.position;
|
||||
|
||||
expect(
|
||||
utils.isDiscussionApplicableToLine(
|
||||
utils.isDiscussionApplicableToLine({
|
||||
discussion,
|
||||
{
|
||||
diffPosition: {
|
||||
...diffPosition,
|
||||
lineCode: 'ABC_1',
|
||||
},
|
||||
false,
|
||||
),
|
||||
latestDiff: false,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue