summaryrefslogtreecommitdiff
path: root/spec/javascripts
diff options
context:
space:
mode:
authorSam Bigelow <sbigelow@gitlab.com>2018-12-17 20:25:41 -0500
committerSam Bigelow <sbigelow@gitlab.com>2018-12-17 20:25:41 -0500
commit9c18798275d455c78ebdac2f1ed6d25112c558fa (patch)
tree09ce9951bee850e03229419b1d9d551a35bfc5d8 /spec/javascripts
parent8b4602041cf2c4a8738a4796d78720017249249f (diff)
downloadgitlab-ce-9c18798275d455c78ebdac2f1ed6d25112c558fa.tar.gz
Utilize :key to minimize extra rerenders
The diff notes automatically focus on mount, and when using the index (as opposed to line_code) for the v-bind:key, the comment form gets unnecessarily remounted, and therefore refocused.
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/diffs/store/utils_spec.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/spec/javascripts/diffs/store/utils_spec.js b/spec/javascripts/diffs/store/utils_spec.js
index f096638e3d6..4268634d302 100644
--- a/spec/javascripts/diffs/store/utils_spec.js
+++ b/spec/javascripts/diffs/store/utils_spec.js
@@ -294,10 +294,14 @@ describe('DiffsStoreUtils', () => {
});
describe('prepareDiffData', () => {
- it('sets the renderIt and collapsed attribute on files', () => {
- const preparedDiff = { diff_files: [getDiffFileMock()] };
+ let preparedDiff;
+
+ beforeEach(() => {
+ preparedDiff = { diff_files: [getDiffFileMock()] };
utils.prepareDiffData(preparedDiff);
+ });
+ it('sets the renderIt and collapsed attribute on files', () => {
const firstParallelDiffLine = preparedDiff.diff_files[0].parallel_diff_lines[2];
expect(firstParallelDiffLine.left.discussions.length).toBe(0);
@@ -323,6 +327,18 @@ describe('DiffsStoreUtils', () => {
expect(preparedDiff.diff_files[0].renderIt).toBeTruthy();
expect(preparedDiff.diff_files[0].collapsed).toBeFalsy();
});
+
+ it('adds line_code to all lines', () => {
+ expect(
+ preparedDiff.diff_files[0].parallel_diff_lines.filter(line => !line.line_code),
+ ).toHaveLength(0);
+ });
+
+ it('uses right line code if left has none', () => {
+ const firstLine = preparedDiff.diff_files[0].parallel_diff_lines[0];
+
+ expect(firstLine.line_code).toEqual(firstLine.right.line_code);
+ });
});
describe('isDiscussionApplicableToLine', () => {