diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2019-03-23 17:52:35 +0100 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2019-03-23 17:53:46 +0100 |
commit | 514ee63826e47229bfd03bdbb740f2dd1eae1d03 (patch) | |
tree | 3f0d96a4402e8aa54c375084cc4c5e6cf546824b /spec/javascripts/diffs | |
parent | 6d330015dfdb1979a0773c87c53b84cc86b28a6d (diff) | |
download | gitlab-ce-514ee63826e47229bfd03bdbb740f2dd1eae1d03.tar.gz |
Move some tests from Karma to Jest
Diffstat (limited to 'spec/javascripts/diffs')
4 files changed, 0 insertions, 182 deletions
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); - }); -}); |