Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
f23737a4
Commit
f23737a4
authored
Apr 08, 2019
by
Winnie Hellmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor diff_spec.js to use table-based tests
parent
61d08f57
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
48 deletions
+45
-48
spec/frontend/ide/lib/diff/diff_spec.js
spec/frontend/ide/lib/diff/diff_spec.js
+45
-48
No files found.
spec/frontend/ide/lib/diff/diff_spec.js
View file @
f23737a4
...
...
@@ -9,60 +9,57 @@ describe('Multi-file editor library diff calculator', () => {
});
describe
(
'
modified
'
,
()
=>
{
it
(
''
,
()
=>
{
const
diff
=
computeDiff
(
'
123
'
,
'
1234
'
)[
0
];
expect
(
diff
.
added
).
toBeTruthy
();
expect
(
diff
.
modified
).
toBeTruthy
();
expect
(
diff
.
removed
).
toBeUndefined
();
});
it
(
''
,
()
=>
{
const
diff
=
computeDiff
(
'
123
\n
123
\n
123
'
,
'
123
\n
1234
\n
123
'
)[
0
];
expect
(
diff
.
added
).
toBeTruthy
();
expect
(
diff
.
modified
).
toBeTruthy
();
expect
(
diff
.
removed
).
toBeUndefined
();
expect
(
diff
.
lineNumber
).
toBe
(
2
);
});
it
.
each
`
originalContent | newContent | lineNumber
${
'
123
'
}
|
${
'
1234
'
}
|
${
1
}
${
'
123
\n
123
\n
123
'
}
|
${
'
123
\n
1234
\n
123
'
}
|
${
2
}
`
(
'
marks line $lineNumber as added and modified but not removed
'
,
({
originalContent
,
newContent
,
lineNumber
})
=>
{
const
diff
=
computeDiff
(
originalContent
,
newContent
)[
0
];
expect
(
diff
.
added
).
toBeTruthy
();
expect
(
diff
.
modified
).
toBeTruthy
();
expect
(
diff
.
removed
).
toBeUndefined
();
expect
(
diff
.
lineNumber
).
toBe
(
lineNumber
);
},
);
});
describe
(
'
added
'
,
()
=>
{
it
(
''
,
()
=>
{
const
diff
=
computeDiff
(
'
123
'
,
'
123
\n
123
'
)[
0
];
expect
(
diff
.
added
).
toBeTruthy
();
expect
(
diff
.
modified
).
toBeUndefined
();
expect
(
diff
.
removed
).
toBeUndefined
();
});
it
(
''
,
()
=>
{
const
diff
=
computeDiff
(
'
123
\n
123
\n
123
'
,
'
123
\n
123
\n
1234
\n
123
'
)[
0
];
expect
(
diff
.
added
).
toBeTruthy
();
expect
(
diff
.
modified
).
toBeUndefined
();
expect
(
diff
.
removed
).
toBeUndefined
();
expect
(
diff
.
lineNumber
).
toBe
(
3
);
});
it
.
each
`
originalContent | newContent | lineNumber
${
'
123
'
}
|
${
'
123
\n
123
'
}
|
${
1
}
${
'
123
\n
123
\n
123
'
}
|
${
'
123
\n
123
\n
1234
\n
123
'
}
|
${
3
}
`
(
'
marks line $lineNumber as added but not modified and not removed
'
,
({
originalContent
,
newContent
,
lineNumber
})
=>
{
const
diff
=
computeDiff
(
originalContent
,
newContent
)[
0
];
expect
(
diff
.
added
).
toBeTruthy
();
expect
(
diff
.
modified
).
toBeUndefined
();
expect
(
diff
.
removed
).
toBeUndefined
();
expect
(
diff
.
lineNumber
).
toBe
(
lineNumber
);
},
);
});
describe
(
'
removed
'
,
()
=>
{
it
(
''
,
()
=>
{
const
diff
=
computeDiff
(
'
123
'
,
''
)[
0
];
expect
(
diff
.
added
).
toBeUndefined
();
expect
(
diff
.
modified
).
toBeUndefined
();
expect
(
diff
.
removed
).
toBeTruthy
();
});
it
(
''
,
()
=>
{
const
diff
=
computeDiff
(
'
123
\n
123
\n
123
'
,
'
123
\n
123
'
)[
0
];
expect
(
diff
.
added
).
toBeUndefined
();
expect
(
diff
.
modified
).
toBeTruthy
();
expect
(
diff
.
removed
).
toBeTruthy
();
expect
(
diff
.
lineNumber
).
toBe
(
2
);
});
it
.
each
`
originalContent | newContent | lineNumber | modified
${
'
123
'
}
|
${
''
}
|
${
1
}
|
${
undefined
}
${
'
123
\n
123
\n
123
'
}
|
${
'
123
\n
123
'
}
|
${
2
}
|
${
true
}
`
(
'
marks line $lineNumber as removed
'
,
({
originalContent
,
newContent
,
lineNumber
,
modified
})
=>
{
const
diff
=
computeDiff
(
originalContent
,
newContent
)[
0
];
expect
(
diff
.
added
).
toBeUndefined
();
expect
(
diff
.
modified
).
toBe
(
modified
);
expect
(
diff
.
removed
).
toBeTruthy
();
expect
(
diff
.
lineNumber
).
toBe
(
lineNumber
);
},
);
});
it
(
'
includes line number of change
'
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment