diff options
Diffstat (limited to 'spec/frontend/diffs')
6 files changed, 13 insertions, 44 deletions
diff --git a/spec/frontend/diffs/components/commit_item_spec.js b/spec/frontend/diffs/components/commit_item_spec.js index eee17e118a0..e52c5abbc7b 100644 --- a/spec/frontend/diffs/components/commit_item_spec.js +++ b/spec/frontend/diffs/components/commit_item_spec.js @@ -6,8 +6,6 @@ import Component from '~/diffs/components/commit_item.vue'; import { getTimeago } from '~/lib/utils/datetime_utility'; import CommitPipelineStatus from '~/projects/tree/components/commit_pipeline_status_component.vue'; -jest.mock('~/user_popovers'); - const TEST_AUTHOR_NAME = 'test'; const TEST_AUTHOR_EMAIL = 'test+test@gitlab.com'; const TEST_AUTHOR_GRAVATAR = `${TEST_HOST}/avatar/test?s=40`; diff --git a/spec/frontend/diffs/components/diff_expansion_cell_spec.js b/spec/frontend/diffs/components/diff_expansion_cell_spec.js index bd538996349..5ff0728b358 100644 --- a/spec/frontend/diffs/components/diff_expansion_cell_spec.js +++ b/spec/frontend/diffs/components/diff_expansion_cell_spec.js @@ -1,4 +1,3 @@ -import { getByText } from '@testing-library/dom'; import { mount } from '@vue/test-utils'; import { cloneDeep } from 'lodash'; import DiffExpansionCell from '~/diffs/components/diff_expansion_cell.vue'; @@ -81,7 +80,7 @@ describe('DiffExpansionCell', () => { const findExpandUp = (wrapper) => wrapper.find(EXPAND_UP_CLASS); const findExpandDown = (wrapper) => wrapper.find(EXPAND_DOWN_CLASS); - const findExpandAll = ({ element }) => getByText(element, 'Show all unchanged lines'); + const findExpandAll = (wrapper) => wrapper.find('.js-unfold-all'); describe('top row', () => { it('should have "expand up" and "show all" option', () => { @@ -90,9 +89,7 @@ describe('DiffExpansionCell', () => { }); expect(findExpandUp(wrapper).exists()).toBe(true); - expect(findExpandDown(wrapper).exists()).toBe(true); expect(findExpandUp(wrapper).attributes('disabled')).not.toBeDefined(); - expect(findExpandDown(wrapper).attributes('disabled')).toBeDefined(); expect(findExpandAll(wrapper)).not.toBe(null); }); }); @@ -114,9 +111,7 @@ describe('DiffExpansionCell', () => { }); expect(findExpandDown(wrapper).exists()).toBe(true); - expect(findExpandUp(wrapper).exists()).toBe(true); expect(findExpandDown(wrapper).attributes('disabled')).not.toBeDefined(); - expect(findExpandUp(wrapper).attributes('disabled')).toBeDefined(); expect(findExpandAll(wrapper)).not.toBe(null); }); }); @@ -144,9 +139,9 @@ describe('DiffExpansionCell', () => { newLineNumber, }); - const wrapper = createComponent({ file }); + const wrapper = createComponent({ file, lineCountBetween: 10 }); - findExpandAll(wrapper).click(); + findExpandAll(wrapper).trigger('click'); expect(store.dispatch).toHaveBeenCalledWith( 'diffs/loadMoreLines', diff --git a/spec/frontend/diffs/components/diff_file_header_spec.js b/spec/frontend/diffs/components/diff_file_header_spec.js index f22bd312a6d..d90afeb6b82 100644 --- a/spec/frontend/diffs/components/diff_file_header_spec.js +++ b/spec/frontend/diffs/components/diff_file_header_spec.js @@ -14,7 +14,6 @@ import { scrollToElement } from '~/lib/utils/common_utils'; import { truncateSha } from '~/lib/utils/text_utility'; import { __, sprintf } from '~/locale'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; -import FileIcon from '~/vue_shared/components/file_icon.vue'; import testAction from '../../__helpers__/vuex_action_helper'; import diffDiscussionsMockData from '../mock_data/diff_discussions'; @@ -224,16 +223,6 @@ describe('DiffFileHeader component', () => { }); expect(findFileActions().exists()).toBe(false); }); - - it('renders submodule icon', () => { - createComponent({ - props: { - diffFile: submoduleDiffFile, - }, - }); - - expect(wrapper.find(FileIcon).props('submodule')).toBe(true); - }); }); describe('for any file', () => { diff --git a/spec/frontend/diffs/components/diff_line_note_form_spec.js b/spec/frontend/diffs/components/diff_line_note_form_spec.js index fb9dc22ce25..b59043168b8 100644 --- a/spec/frontend/diffs/components/diff_line_note_form_spec.js +++ b/spec/frontend/diffs/components/diff_line_note_form_spec.js @@ -64,6 +64,16 @@ describe('DiffLineNoteForm', () => { expect(confirmAction).toHaveBeenCalled(); }); + it('should only ask for confirmation once', () => { + // Never resolve so we can test what happens when triggered while "confirmAction" is loading + confirmAction.mockImplementation(() => new Promise(() => {})); + + findNoteForm().vm.$emit('cancelForm', true, true); + findNoteForm().vm.$emit('cancelForm', true, true); + + expect(confirmAction).toHaveBeenCalledTimes(1); + }); + it('should not ask for confirmation when one of the params false', () => { confirmAction.mockResolvedValueOnce(false); diff --git a/spec/frontend/diffs/components/diff_view_spec.js b/spec/frontend/diffs/components/diff_view_spec.js index f982749d1de..dfbe30e460b 100644 --- a/spec/frontend/diffs/components/diff_view_spec.js +++ b/spec/frontend/diffs/components/diff_view_spec.js @@ -49,22 +49,6 @@ describe('DiffView', () => { return shallowMount(DiffView, { propsData, store, stubs }); }; - it('renders a match line', () => { - const wrapper = createWrapper({ - diffLines: [ - { - isMatchLineLeft: true, - left: { - rich_text: '@@ -4,12 +4,12 @@ import createFlash from '~/flash';', - lineDraft: {}, - }, - }, - ], - }); - expect(wrapper.find(DiffExpansionCell).exists()).toBe(true); - expect(wrapper.text()).toContain("@@ -4,12 +4,12 @@ import createFlash from '~/flash';"); - }); - it.each` type | side | container | sides | total ${'parallel'} | ${'left'} | ${'.old'} | ${{ left: { lineDraft: {}, renderDiscussion: true }, right: { lineDraft: {}, renderDiscussion: true } }} | ${2} diff --git a/spec/frontend/diffs/store/utils_spec.js b/spec/frontend/diffs/store/utils_spec.js index 8ae51a58819..6f55f76d7b5 100644 --- a/spec/frontend/diffs/store/utils_spec.js +++ b/spec/frontend/diffs/store/utils_spec.js @@ -30,13 +30,6 @@ describe('DiffsStoreUtils', () => { }); }); - describe('getReversePosition', () => { - it('should return correct line position name', () => { - expect(utils.getReversePosition(LINE_POSITION_RIGHT)).toEqual(LINE_POSITION_LEFT); - expect(utils.getReversePosition(LINE_POSITION_LEFT)).toEqual(LINE_POSITION_RIGHT); - }); - }); - describe('findIndexInInlineLines', () => { const expectSet = (method, lines, invalidLines) => { expect(method(lines, { oldLineNumber: 3, newLineNumber: 5 })).toEqual(4); |