summaryrefslogtreecommitdiff
path: root/spec/javascripts/diffs
diff options
context:
space:
mode:
Diffstat (limited to 'spec/javascripts/diffs')
-rw-r--r--spec/javascripts/diffs/components/diff_file_header_spec.js3
-rw-r--r--spec/javascripts/diffs/components/diff_stats_spec.js33
-rw-r--r--spec/javascripts/diffs/components/edit_button_spec.js61
-rw-r--r--spec/javascripts/diffs/components/hidden_files_warning_spec.js48
-rw-r--r--spec/javascripts/diffs/components/no_changes_spec.js40
-rw-r--r--spec/javascripts/diffs/mock_data/diff_discussions.js2
6 files changed, 1 insertions, 186 deletions
diff --git a/spec/javascripts/diffs/components/diff_file_header_spec.js b/spec/javascripts/diffs/components/diff_file_header_spec.js
index 66c5b17b825..e10193c25b7 100644
--- a/spec/javascripts/diffs/components/diff_file_header_spec.js
+++ b/spec/javascripts/diffs/components/diff_file_header_spec.js
@@ -23,9 +23,6 @@ describe('diff_file_header', () => {
});
beforeEach(() => {
- gon.features = {
- expandDiffFullFile: true,
- };
const diffFile = diffDiscussionMock.diff_file;
diffFile.added_lines = 2;
diff --git a/spec/javascripts/diffs/components/diff_stats_spec.js b/spec/javascripts/diffs/components/diff_stats_spec.js
deleted file mode 100644
index 984b3026209..00000000000
--- a/spec/javascripts/diffs/components/diff_stats_spec.js
+++ /dev/null
@@ -1,33 +0,0 @@
-import { shallowMount } from '@vue/test-utils';
-import DiffStats from '~/diffs/components/diff_stats.vue';
-
-describe('diff_stats', () => {
- it('does not render a group if diffFileLengths is not passed in', () => {
- const wrapper = shallowMount(DiffStats, {
- propsData: {
- addedLines: 1,
- removedLines: 2,
- },
- });
- const groups = wrapper.findAll('.diff-stats-group');
-
- expect(groups.length).toBe(2);
- });
-
- it('shows amount of files changed, lines added and lines removed when passed all props', () => {
- const wrapper = shallowMount(DiffStats, {
- propsData: {
- addedLines: 100,
- removedLines: 200,
- diffFilesLength: 300,
- },
- });
- const additions = wrapper.find('icon-stub[name="file-addition"]').element.parentNode;
- const deletions = wrapper.find('icon-stub[name="file-deletion"]').element.parentNode;
- const filesChanged = wrapper.find('icon-stub[name="doc-code"]').element.parentNode;
-
- expect(additions.textContent).toContain('100');
- expect(deletions.textContent).toContain('200');
- expect(filesChanged.textContent).toContain('300');
- });
-});
diff --git a/spec/javascripts/diffs/components/edit_button_spec.js b/spec/javascripts/diffs/components/edit_button_spec.js
deleted file mode 100644
index ccdae4cb312..00000000000
--- a/spec/javascripts/diffs/components/edit_button_spec.js
+++ /dev/null
@@ -1,61 +0,0 @@
-import { shallowMount, createLocalVue } from '@vue/test-utils';
-import EditButton from '~/diffs/components/edit_button.vue';
-
-const localVue = createLocalVue();
-const editPath = 'test-path';
-
-describe('EditButton', () => {
- let wrapper;
-
- const createComponent = (props = {}) => {
- wrapper = shallowMount(EditButton, {
- localVue,
- sync: false,
- propsData: { ...props },
- });
- };
-
- afterEach(() => {
- wrapper.destroy();
- });
-
- it('has correct href attribute', () => {
- createComponent({
- editPath,
- canCurrentUserFork: false,
- });
-
- expect(wrapper.attributes('href')).toBe(editPath);
- });
-
- it('emits a show fork message event if current user can fork', () => {
- createComponent({
- editPath,
- canCurrentUserFork: true,
- });
- wrapper.trigger('click');
-
- expect(wrapper.emitted('showForkMessage')).toBeTruthy();
- });
-
- it('doesnt emit a show fork message event if current user cannot fork', () => {
- createComponent({
- editPath,
- canCurrentUserFork: false,
- });
- wrapper.trigger('click');
-
- expect(wrapper.emitted('showForkMessage')).toBeFalsy();
- });
-
- it('doesnt emit a show fork message event if current user can modify blob', () => {
- createComponent({
- editPath,
- canCurrentUserFork: true,
- canModifyBlob: true,
- });
- wrapper.trigger('click');
-
- expect(wrapper.emitted('showForkMessage')).toBeFalsy();
- });
-});
diff --git a/spec/javascripts/diffs/components/hidden_files_warning_spec.js b/spec/javascripts/diffs/components/hidden_files_warning_spec.js
deleted file mode 100644
index 5bf5ddd27bd..00000000000
--- a/spec/javascripts/diffs/components/hidden_files_warning_spec.js
+++ /dev/null
@@ -1,48 +0,0 @@
-import { shallowMount, createLocalVue } from '@vue/test-utils';
-import HiddenFilesWarning from '~/diffs/components/hidden_files_warning.vue';
-
-const localVue = createLocalVue();
-const propsData = {
- total: '10',
- visible: 5,
- plainDiffPath: 'plain-diff-path',
- emailPatchPath: 'email-patch-path',
-};
-
-describe('HiddenFilesWarning', () => {
- let wrapper;
-
- const createComponent = () => {
- wrapper = shallowMount(HiddenFilesWarning, {
- localVue,
- sync: false,
- propsData,
- });
- };
-
- beforeEach(() => {
- createComponent();
- });
-
- afterEach(() => {
- wrapper.destroy();
- });
-
- it('has a correct plain diff URL', () => {
- const plainDiffLink = wrapper.findAll('a').wrappers.filter(x => x.text() === 'Plain diff')[0];
-
- expect(plainDiffLink.attributes('href')).toBe(propsData.plainDiffPath);
- });
-
- it('has a correct email patch URL', () => {
- const emailPatchLink = wrapper.findAll('a').wrappers.filter(x => x.text() === 'Email patch')[0];
-
- expect(emailPatchLink.attributes('href')).toBe(propsData.emailPatchPath);
- });
-
- it('has a correct visible/total files text', () => {
- const filesText = wrapper.find('strong');
-
- expect(filesText.text()).toBe('5 of 10');
- });
-});
diff --git a/spec/javascripts/diffs/components/no_changes_spec.js b/spec/javascripts/diffs/components/no_changes_spec.js
deleted file mode 100644
index e45d34bf9d5..00000000000
--- a/spec/javascripts/diffs/components/no_changes_spec.js
+++ /dev/null
@@ -1,40 +0,0 @@
-import { createLocalVue, shallowMount } from '@vue/test-utils';
-import Vuex from 'vuex';
-import { createStore } from '~/mr_notes/stores';
-import NoChanges from '~/diffs/components/no_changes.vue';
-
-describe('Diff no changes empty state', () => {
- let vm;
-
- function createComponent(extendStore = () => {}) {
- const localVue = createLocalVue();
- localVue.use(Vuex);
-
- const store = createStore();
- extendStore(store);
-
- vm = shallowMount(localVue.extend(NoChanges), {
- localVue,
- store,
- propsData: {
- changesEmptyStateIllustration: '',
- },
- });
- }
-
- afterEach(() => {
- vm.destroy();
- });
-
- it('prevents XSS', () => {
- createComponent(store => {
- // eslint-disable-next-line no-param-reassign
- store.state.notes.noteableData = {
- source_branch: '<script>alert("test");</script>',
- target_branch: '<script>alert("test");</script>',
- };
- });
-
- expect(vm.contains('script')).toBe(false);
- });
-});
diff --git a/spec/javascripts/diffs/mock_data/diff_discussions.js b/spec/javascripts/diffs/mock_data/diff_discussions.js
index fd5dd611383..711ab543411 100644
--- a/spec/javascripts/diffs/mock_data/diff_discussions.js
+++ b/spec/javascripts/diffs/mock_data/diff_discussions.js
@@ -496,7 +496,7 @@ export default {
{
text: 'line',
rich_text:
- '<tr class="line_holder new" id="">\n<td class="diff-line-num new old_line" data-linenumber="1">\n \n</td>\n<td class="diff-line-num new new_line" data-linenumber="1">\n1\n</td>\n<td class="line_content new noteable_line"><span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n</td>\n</tr>\n<tr class="line_holder new" id="">\n<td class="diff-line-num new old_line" data-linenumber="1">\n \n</td>\n<td class="diff-line-num new new_line" data-linenumber="2">\n2\n</td>\n<td class="line_content new noteable_line"><span id="LC2" class="line" lang="plaintext"></span>\n</td>\n</tr>\n',
+ '<tr class="line_holder new" id="">\n<td class="diff-line-num new old_line" data-linenumber="1">\n \n</td>\n<td class="diff-line-num new new_line" data-linenumber="1">\n1\n</td>\n<td class="line_content new"><span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n</td>\n</tr>\n<tr class="line_holder new" id="">\n<td class="diff-line-num new old_line" data-linenumber="1">\n \n</td>\n<td class="diff-line-num new new_line" data-linenumber="2">\n2\n</td>\n<td class="line_content new"><span id="LC2" class="line" lang="plaintext"></span>\n</td>\n</tr>\n',
can_receive_suggestion: true,
line_code: '6f209374f7e565f771b95720abf46024c41d1885_1_1',
type: 'new',