Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-13 18:08:52 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-13 18:08:52 +0300
commit0ab47b994caa80c5587f33dc818626b66cfdafe2 (patch)
tree5ef3976d2f84e3368903a67ba2dbd87a74b9a43c /spec/frontend/diffs
parent1308dc5eb484ab0f8064989fc551ebdb4b1a7976 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/diffs')
-rw-r--r--spec/frontend/diffs/components/diff_table_cell_spec.js (renamed from spec/frontend/diffs/components/diff_line_gutter_content_spec.js)44
1 files changed, 31 insertions, 13 deletions
diff --git a/spec/frontend/diffs/components/diff_line_gutter_content_spec.js b/spec/frontend/diffs/components/diff_table_cell_spec.js
index 0553498bfa0..1af0746f3bd 100644
--- a/spec/frontend/diffs/components/diff_line_gutter_content_spec.js
+++ b/spec/frontend/diffs/components/diff_table_cell_spec.js
@@ -1,6 +1,6 @@
+import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex';
-import { shallowMount, createLocalVue } from '@vue/test-utils';
-import DiffLineGutterContent from '~/diffs/components/diff_line_gutter_content.vue';
+import DiffTableCell from '~/diffs/components/diff_table_cell.vue';
import DiffGutterAvatars from '~/diffs/components/diff_gutter_avatars.vue';
import { LINE_POSITION_RIGHT } from '~/diffs/constants';
import { createStore } from '~/mr_notes/stores';
@@ -17,7 +17,7 @@ const TEST_LINE_NUMBER = 1;
const TEST_LINE_CODE = 'LC_42';
const TEST_FILE_HASH = diffFileMockData.file_hash;
-describe('DiffLineGutterContent', () => {
+describe('DiffTableCell', () => {
let wrapper;
let line;
let store;
@@ -49,22 +49,40 @@ describe('DiffLineGutterContent', () => {
value,
});
};
+
const createComponent = (props = {}) => {
- wrapper = shallowMount(DiffLineGutterContent, {
+ wrapper = shallowMount(DiffTableCell, {
localVue,
store,
propsData: {
line,
fileHash: TEST_FILE_HASH,
contextLinesPath: '/context/lines/path',
+ isHighlighted: false,
...props,
},
});
};
- const findNoteButton = () => wrapper.find('.js-add-diff-note-button');
+
+ const findTd = () => wrapper.find({ ref: 'td' });
+ const findNoteButton = () => wrapper.find({ ref: 'addDiffNoteButton' });
const findLineNumber = () => wrapper.find({ ref: 'lineNumberRef' });
const findAvatars = () => wrapper.find(DiffGutterAvatars);
+ describe('td', () => {
+ it('highlights when isHighlighted true', () => {
+ createComponent({ isHighlighted: true });
+
+ expect(findTd().classes()).toContain('hll');
+ });
+
+ it('does not highlight when isHighlighted false', () => {
+ createComponent({ isHighlighted: false });
+
+ expect(findTd().classes()).not.toContain('hll');
+ });
+ });
+
describe('comment button', () => {
it.each`
showCommentButton | userData | query | expectation
@@ -84,13 +102,13 @@ describe('DiffLineGutterContent', () => {
);
it.each`
- isHover | otherProps | discussions | expectation
- ${true} | ${{}} | ${[]} | ${true}
- ${false} | ${{}} | ${[]} | ${false}
- ${true} | ${{ isMatchLine: true }} | ${[]} | ${false}
- ${true} | ${{ isContextLine: true }} | ${[]} | ${false}
- ${true} | ${{ isMetaLine: true }} | ${[]} | ${false}
- ${true} | ${{}} | ${[{}]} | ${false}
+ isHover | otherProps | discussions | expectation
+ ${true} | ${{}} | ${[]} | ${true}
+ ${false} | ${{}} | ${[]} | ${false}
+ ${true} | ${{ line: { ...line, type: 'match' } }} | ${[]} | ${false}
+ ${true} | ${{ line: { ...line, type: 'context' } }} | ${[]} | ${false}
+ ${true} | ${{ line: { ...line, type: 'old-nonewline' } }} | ${[]} | ${false}
+ ${true} | ${{}} | ${[{}]} | ${false}
`(
'visible is $expectation - with isHover ($isHover), discussions ($discussions), otherProps ($otherProps)',
({ isHover, otherProps, discussions, expectation }) => {
@@ -109,7 +127,7 @@ describe('DiffLineGutterContent', () => {
describe('line number', () => {
describe('without lineNumber prop', () => {
it('does not render', () => {
- createComponent();
+ createComponent({ lineType: 'old' });
expect(findLineNumber().exists()).toBe(false);
});