summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2018-06-24 23:14:42 +0200
committerFatih Acet <acetfatih@gmail.com>2018-06-24 23:14:42 +0200
commit64a178e3c5f5085441f27e740240f035e2a6c4d1 (patch)
tree4ad3ded7bcc84bbb3121e7a70cef2be078897d5f
parent7327a639753a0b6930e2917a39ffd7590eef41fe (diff)
downloadgitlab-ce-_diff-lines-refactor.tar.gz
Remove deprecated specs for diff line components._diff-lines-refactor
-rw-r--r--app/assets/javascripts/diffs/components/parallel_diff_view.vue3
-rw-r--r--spec/javascripts/diffs/components/diff_line_gutter_content_spec.js41
-rw-r--r--spec/javascripts/diffs/components/inline_diff_view_spec.js64
-rw-r--r--spec/javascripts/diffs/components/parallel_diff_view_spec.js166
4 files changed, 3 insertions, 271 deletions
diff --git a/app/assets/javascripts/diffs/components/parallel_diff_view.vue b/app/assets/javascripts/diffs/components/parallel_diff_view.vue
index 682e87872d9..ed92b4ee249 100644
--- a/app/assets/javascripts/diffs/components/parallel_diff_view.vue
+++ b/app/assets/javascripts/diffs/components/parallel_diff_view.vue
@@ -28,7 +28,8 @@ export default {
<div
:class="userColorScheme"
:data-commit-id="commitId"
- class="code diff-wrap-lines js-syntax-highlight text-file">
+ class="code diff-wrap-lines js-syntax-highlight text-file"
+ >
<table>
<tbody>
<template
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 312a684f4d2..dd451a39655 100644
--- a/spec/javascripts/diffs/components/diff_line_gutter_content_spec.js
+++ b/spec/javascripts/diffs/components/diff_line_gutter_content_spec.js
@@ -31,45 +31,6 @@ describe('DiffLineGutterContent', () => {
};
describe('computed', () => {
- describe('isMatchLine', () => {
- it('should return true for match line type', () => {
- const component = createComponent({ lineType: MATCH_LINE_TYPE });
- expect(component.isMatchLine).toEqual(true);
- });
-
- it('should return false for non-match line type', () => {
- const component = createComponent({ lineType: CONTEXT_LINE_TYPE });
- expect(component.isMatchLine).toEqual(false);
- });
- });
-
- describe('isContextLine', () => {
- it('should return true for context line type', () => {
- const component = createComponent({ lineType: CONTEXT_LINE_TYPE });
- expect(component.isContextLine).toEqual(true);
- });
-
- it('should return false for non-context line type', () => {
- const component = createComponent({ lineType: MATCH_LINE_TYPE });
- expect(component.isContextLine).toEqual(false);
- });
- });
-
- describe('isMetaLine', () => {
- it('should return true for meta line type', () => {
- const component = createComponent({ lineType: NEW_NO_NEW_LINE_TYPE });
- expect(component.isMetaLine).toEqual(true);
-
- const component2 = createComponent({ lineType: OLD_NO_NEW_LINE_TYPE });
- expect(component2.isMetaLine).toEqual(true);
- });
-
- it('should return false for non-meta line type', () => {
- const component = createComponent({ lineType: MATCH_LINE_TYPE });
- expect(component.isMetaLine).toEqual(false);
- });
- });
-
describe('lineHref', () => {
it('should prepend # to lineCode', () => {
const lineCode = 'LC_42';
@@ -109,7 +70,7 @@ describe('DiffLineGutterContent', () => {
describe('template', () => {
it('should render three dots for context lines', () => {
const component = createComponent({
- lineType: MATCH_LINE_TYPE,
+ isMatchLine: true,
});
expect(component.$el.querySelector('span').classList.contains('context-cell')).toEqual(true);
diff --git a/spec/javascripts/diffs/components/inline_diff_view_spec.js b/spec/javascripts/diffs/components/inline_diff_view_spec.js
index 0d5a3576204..85d731d0cd4 100644
--- a/spec/javascripts/diffs/components/inline_diff_view_spec.js
+++ b/spec/javascripts/diffs/components/inline_diff_view_spec.js
@@ -20,52 +20,6 @@ describe('InlineDiffView', () => {
}).$mount();
});
- describe('methods', () => {
- describe('handleMouse', () => {
- it('should set hoveredLineCode', () => {
- expect(component.hoveredLineCode).toEqual(null);
-
- component.handleMouse('lineCode1', true);
- expect(component.hoveredLineCode).toEqual('lineCode1');
-
- component.handleMouse('lineCode1', false);
- expect(component.hoveredLineCode).toEqual(null);
- });
- });
-
- describe('getLineClass', () => {
- it('should return line class object', () => {
- const { LINE_HOVER_CLASS_NAME, LINE_UNFOLD_CLASS_NAME } = constants;
- const { MATCH_LINE_TYPE, NEW_LINE_TYPE } = constants;
-
- expect(component.getLineClass(component.diffLines[0])).toEqual({
- [NEW_LINE_TYPE]: NEW_LINE_TYPE,
- [LINE_UNFOLD_CLASS_NAME]: false,
- [LINE_HOVER_CLASS_NAME]: false,
- });
-
- component.handleMouse(component.diffLines[0].lineCode, true);
- Object.defineProperty(component, 'isLoggedIn', {
- get() {
- return true;
- },
- });
-
- expect(component.getLineClass(component.diffLines[0])).toEqual({
- [NEW_LINE_TYPE]: NEW_LINE_TYPE,
- [LINE_UNFOLD_CLASS_NAME]: false,
- [LINE_HOVER_CLASS_NAME]: true,
- });
-
- expect(component.getLineClass(component.diffLines[5])).toEqual({
- [MATCH_LINE_TYPE]: MATCH_LINE_TYPE,
- [LINE_UNFOLD_CLASS_NAME]: true,
- [LINE_HOVER_CLASS_NAME]: false,
- });
- });
- });
- });
-
describe('template', () => {
it('should have rendered diff lines', () => {
const el = component.$el;
@@ -89,23 +43,5 @@ describe('InlineDiffView', () => {
done();
});
});
-
- it('should render new discussion forms', done => {
- const el = component.$el;
- const lines = getDiffFileMock().highlightedDiffLines;
-
- component.handleShowCommentForm({ lineCode: lines[0].lineCode });
- component.handleShowCommentForm({ lineCode: lines[1].lineCode });
-
- Vue.nextTick(() => {
- expect(el.querySelectorAll('.js-vue-markdown-field').length).toEqual(2);
- expect(el.querySelectorAll('tr')[1].classList.contains('notes_holder')).toEqual(true);
- expect(el.querySelectorAll('tr')[3].classList.contains('notes_holder')).toEqual(true);
-
- store.state.diffs.diffLineCommentForms = {};
-
- done();
- });
- });
});
});
diff --git a/spec/javascripts/diffs/components/parallel_diff_view_spec.js b/spec/javascripts/diffs/components/parallel_diff_view_spec.js
index cab533217c0..07850163b01 100644
--- a/spec/javascripts/diffs/components/parallel_diff_view_spec.js
+++ b/spec/javascripts/diffs/components/parallel_diff_view_spec.js
@@ -29,154 +29,6 @@ describe('ParallelDiffView', () => {
});
});
- describe('methods', () => {
- describe('hasDiscussion', () => {
- it('it should return true if there is a discussion either for left or right section', () => {
- Object.defineProperty(component, 'discussionsByLineCode', {
- get() {
- return { line_42: true };
- },
- });
-
- expect(component.hasDiscussion({ left: {}, right: {} })).toEqual(undefined);
- expect(component.hasDiscussion({ left: { lineCode: 'line_42' }, right: {} })).toEqual(true);
- expect(component.hasDiscussion({ left: {}, right: { lineCode: 'line_42' } })).toEqual(true);
- });
- });
-
- describe('getClassName', () => {
- it('should return line class object', () => {
- const { LINE_HOVER_CLASS_NAME, LINE_UNFOLD_CLASS_NAME } = constants;
- const { MATCH_LINE_TYPE, NEW_LINE_TYPE, LINE_POSITION_RIGHT } = constants;
-
- expect(component.getClassName(component.diffLines[1], LINE_POSITION_RIGHT)).toEqual({
- [NEW_LINE_TYPE]: NEW_LINE_TYPE,
- [LINE_UNFOLD_CLASS_NAME]: false,
- [LINE_HOVER_CLASS_NAME]: false,
- });
-
- const eventMock = {
- target: component.$refs.rightLines[1],
- };
-
- component.handleMouse(eventMock, component.diffLines[1], true);
- Object.defineProperty(component, 'isLoggedIn', {
- get() {
- return true;
- },
- });
-
- expect(component.getClassName(component.diffLines[1], LINE_POSITION_RIGHT)).toEqual({
- [NEW_LINE_TYPE]: NEW_LINE_TYPE,
- [LINE_UNFOLD_CLASS_NAME]: false,
- [LINE_HOVER_CLASS_NAME]: true,
- });
-
- expect(component.getClassName(component.diffLines[5], LINE_POSITION_RIGHT)).toEqual({
- [MATCH_LINE_TYPE]: MATCH_LINE_TYPE,
- [LINE_UNFOLD_CLASS_NAME]: true,
- [LINE_HOVER_CLASS_NAME]: false,
- });
- });
- });
-
- describe('handleMouse', () => {
- it('should set hovered line code and line section to null when isHover is false', () => {
- const rightLineEventMock = { target: component.$refs.rightLines[1] };
- expect(component.hoveredLineCode).toEqual(null);
- expect(component.hoveredSection).toEqual(null);
-
- component.handleMouse(rightLineEventMock, null, false);
- expect(component.hoveredLineCode).toEqual(null);
- expect(component.hoveredSection).toEqual(null);
- });
-
- it('should set hovered line code and line section for right section', () => {
- const rightLineEventMock = { target: component.$refs.rightLines[1] };
- component.handleMouse(rightLineEventMock, component.diffLines[1], true);
- expect(component.hoveredLineCode).toEqual(component.diffLines[1].right.lineCode);
- expect(component.hoveredSection).toEqual(constants.LINE_POSITION_RIGHT);
- });
-
- it('should set hovered line code and line section for left section', () => {
- const leftLineEventMock = { target: component.$refs.leftLines[2] };
- component.handleMouse(leftLineEventMock, component.diffLines[2], true);
- expect(component.hoveredLineCode).toEqual(component.diffLines[2].left.lineCode);
- expect(component.hoveredSection).toEqual(constants.LINE_POSITION_LEFT);
- });
- });
-
- describe('shouldRenderDiscussions', () => {
- it('should return true if there is a discussion on left side and it is expanded', () => {
- const line = { left: { lineCode: 'lineCode1' } };
- spyOn(component, 'isDiscussionExpanded').and.returnValue(true);
- Object.defineProperty(component, 'discussionsByLineCode', {
- get() {
- return {
- [line.left.lineCode]: true,
- };
- },
- });
-
- expect(component.shouldRenderDiscussions(line, constants.LINE_POSITION_LEFT)).toEqual(true);
- expect(component.isDiscussionExpanded).toHaveBeenCalledWith(line.left.lineCode);
- });
-
- it('should return false if there is a discussion on left side but it is collapsed', () => {
- const line = { left: { lineCode: 'lineCode1' } };
- spyOn(component, 'isDiscussionExpanded').and.returnValue(false);
- Object.defineProperty(component, 'discussionsByLineCode', {
- get() {
- return {
- [line.left.lineCode]: true,
- };
- },
- });
-
- expect(component.shouldRenderDiscussions(line, constants.LINE_POSITION_LEFT)).toEqual(
- false,
- );
- });
-
- it('should return false for discussions on the right side if there is no line type', () => {
- const CUSTOM_RIGHT_LINE_TYPE = 'CUSTOM_RIGHT_LINE_TYPE';
- const line = { right: { lineCode: 'lineCode1', type: CUSTOM_RIGHT_LINE_TYPE } };
- spyOn(component, 'isDiscussionExpanded').and.returnValue(true);
- Object.defineProperty(component, 'discussionsByLineCode', {
- get() {
- return {
- [line.right.lineCode]: true,
- };
- },
- });
-
- expect(component.shouldRenderDiscussions(line, constants.LINE_POSITION_RIGHT)).toEqual(
- CUSTOM_RIGHT_LINE_TYPE,
- );
- });
- });
-
- describe('hasAnyExpandedDiscussion', () => {
- const LINE_CODE_LEFT = 'LINE_CODE_LEFT';
- const LINE_CODE_RIGHT = 'LINE_CODE_RIGHT';
-
- it('should return true if there is a discussion either on the left or the right side', () => {
- const mockLineOne = {
- right: { lineCode: LINE_CODE_RIGHT },
- left: {},
- };
- const mockLineTwo = {
- left: { lineCode: LINE_CODE_LEFT },
- right: {},
- };
-
- spyOn(component, 'isDiscussionExpanded').and.callFake(lc => lc === LINE_CODE_RIGHT);
- expect(component.hasAnyExpandedDiscussion(mockLineOne)).toEqual(true);
- expect(component.hasAnyExpandedDiscussion(mockLineTwo)).toEqual(false);
- });
- });
- });
-
describe('template', () => {
it('should have rendered diff lines', () => {
const el = component.$el;
@@ -202,23 +54,5 @@ describe('ParallelDiffView', () => {
done();
});
});
-
- it('should render new discussion forms', done => {
- const el = component.$el;
- const lines = getDiffFileMock().parallelDiffLines;
-
- component.handleShowCommentForm({ lineCode: lines[0].lineCode });
- component.handleShowCommentForm({ lineCode: lines[1].lineCode });
-
- Vue.nextTick(() => {
- expect(el.querySelectorAll('.js-vue-markdown-field').length).toEqual(2);
- expect(el.querySelectorAll('tr')[1].classList.contains('notes_holder')).toEqual(true);
- expect(el.querySelectorAll('tr')[3].classList.contains('notes_holder')).toEqual(true);
-
- store.state.diffs.diffLineCommentForms = {};
-
- done();
- });
- });
});
});