diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 14:36:54 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 14:36:54 +0000 |
commit | f61bb2a16a514b71bf33aabbbb999d6732016a24 (patch) | |
tree | 9548caa89e60b4f40b99bbd1dac030420b812aa8 /spec/frontend/diffs/components/commit_item_spec.js | |
parent | 35fc54e5d261f8898e390aea7c2f5ec5fdf0539d (diff) | |
download | gitlab-ce-4a647b2732a66bd1012cef18484571aacad42b5a.tar.gz |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc42
Diffstat (limited to 'spec/frontend/diffs/components/commit_item_spec.js')
-rw-r--r-- | spec/frontend/diffs/components/commit_item_spec.js | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/spec/frontend/diffs/components/commit_item_spec.js b/spec/frontend/diffs/components/commit_item_spec.js index 8cb4fd20063..0191822d97a 100644 --- a/spec/frontend/diffs/components/commit_item_spec.js +++ b/spec/frontend/diffs/components/commit_item_spec.js @@ -13,8 +13,6 @@ const TEST_AUTHOR_EMAIL = 'test+test@gitlab.com'; const TEST_AUTHOR_GRAVATAR = `${TEST_HOST}/avatar/test?s=40`; const TEST_SIGNATURE_HTML = '<a>Legit commit</a>'; const TEST_PIPELINE_STATUS_PATH = `${TEST_HOST}/pipeline/status`; -const NEXT_COMMIT_URL = `${TEST_HOST}/?commit_id=next`; -const PREV_COMMIT_URL = `${TEST_HOST}/?commit_id=prev`; describe('diffs/components/commit_item', () => { let wrapper; @@ -31,12 +29,6 @@ describe('diffs/components/commit_item', () => { const getCommitActionsElement = () => wrapper.find('.commit-actions'); const getCommitPipelineStatus = () => wrapper.find(CommitPipelineStatus); - const getCommitNavButtonsElement = () => wrapper.find('.commit-nav-buttons'); - const getNextCommitNavElement = () => - getCommitNavButtonsElement().find('.btn-group > *:last-child'); - const getPrevCommitNavElement = () => - getCommitNavButtonsElement().find('.btn-group > *:first-child'); - const mountComponent = (propsData) => { wrapper = mount(Component, { propsData: { @@ -180,126 +172,4 @@ describe('diffs/components/commit_item', () => { expect(getCommitPipelineStatus().exists()).toBe(true); }); }); - - describe('without neighbor commits', () => { - beforeEach(() => { - mountComponent({ commit: { ...commit, prev_commit_id: null, next_commit_id: null } }); - }); - - it('does not render any navigation buttons', () => { - expect(getCommitNavButtonsElement().exists()).toEqual(false); - }); - }); - - describe('with neighbor commits', () => { - let mrCommit; - - beforeEach(() => { - mrCommit = { - ...commit, - next_commit_id: 'next', - prev_commit_id: 'prev', - }; - - mountComponent({ commit: mrCommit }); - }); - - it('renders the commit navigation buttons', () => { - expect(getCommitNavButtonsElement().exists()).toEqual(true); - - mountComponent({ - commit: { ...mrCommit, next_commit_id: null }, - }); - expect(getCommitNavButtonsElement().exists()).toEqual(true); - - mountComponent({ - commit: { ...mrCommit, prev_commit_id: null }, - }); - expect(getCommitNavButtonsElement().exists()).toEqual(true); - }); - - describe('prev commit', () => { - const { location } = window; - - beforeAll(() => { - delete window.location; - window.location = { href: `${TEST_HOST}?commit_id=${mrCommit.id}` }; - }); - - beforeEach(() => { - jest.spyOn(wrapper.vm, 'moveToNeighboringCommit').mockImplementation(() => {}); - }); - - afterAll(() => { - window.location = location; - }); - - it('uses the correct href', () => { - const link = getPrevCommitNavElement(); - - expect(link.element.getAttribute('href')).toEqual(PREV_COMMIT_URL); - }); - - it('triggers the correct Vuex action on click', () => { - const link = getPrevCommitNavElement(); - - link.trigger('click'); - return wrapper.vm.$nextTick().then(() => { - expect(wrapper.vm.moveToNeighboringCommit).toHaveBeenCalledWith({ - direction: 'previous', - }); - }); - }); - - it('renders a disabled button when there is no prev commit', () => { - mountComponent({ commit: { ...mrCommit, prev_commit_id: null } }); - - const button = getPrevCommitNavElement(); - - expect(button.element.tagName).toEqual('BUTTON'); - expect(button.element.hasAttribute('disabled')).toEqual(true); - }); - }); - - describe('next commit', () => { - const { location } = window; - - beforeAll(() => { - delete window.location; - window.location = { href: `${TEST_HOST}?commit_id=${mrCommit.id}` }; - }); - - beforeEach(() => { - jest.spyOn(wrapper.vm, 'moveToNeighboringCommit').mockImplementation(() => {}); - }); - - afterAll(() => { - window.location = location; - }); - - it('uses the correct href', () => { - const link = getNextCommitNavElement(); - - expect(link.element.getAttribute('href')).toEqual(NEXT_COMMIT_URL); - }); - - it('triggers the correct Vuex action on click', () => { - const link = getNextCommitNavElement(); - - link.trigger('click'); - return wrapper.vm.$nextTick().then(() => { - expect(wrapper.vm.moveToNeighboringCommit).toHaveBeenCalledWith({ direction: 'next' }); - }); - }); - - it('renders a disabled button when there is no next commit', () => { - mountComponent({ commit: { ...mrCommit, next_commit_id: null } }); - - const button = getNextCommitNavElement(); - - expect(button.element.tagName).toEqual('BUTTON'); - expect(button.element.hasAttribute('disabled')).toEqual(true); - }); - }); - }); }); |