diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-25 15:14:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-25 15:14:14 +0300 |
commit | 868c8c35fbddd439f4df76a5954e2a1caa2af3cc (patch) | |
tree | b7bad2964729ba58b6f84ecf36bc72f939a4c900 /spec/frontend/snippets | |
parent | d2bb55891e78ae23506bee26a30165f3520b47e5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/snippets')
3 files changed, 18 insertions, 19 deletions
diff --git a/spec/frontend/snippets/components/edit_spec.js b/spec/frontend/snippets/components/edit_spec.js index 80a8b8ec489..9f608765183 100644 --- a/spec/frontend/snippets/components/edit_spec.js +++ b/spec/frontend/snippets/components/edit_spec.js @@ -1,7 +1,8 @@ import { GlLoadingIcon } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue, { nextTick } from 'vue'; import { merge } from 'lodash'; -import { nextTick } from 'vue'; + import VueApollo, { ApolloMutation } from 'vue-apollo'; import { useFakeDate } from 'helpers/fake_date'; import createMockApollo from 'helpers/mock_apollo_helper'; @@ -78,8 +79,7 @@ const getApiData = ({ blobActions: [], }); -const localVue = createLocalVue(); -localVue.use(VueApollo); +Vue.use(VueApollo); describe('Snippet Edit app', () => { useFakeDate(); @@ -141,7 +141,6 @@ describe('Snippet Edit app', () => { wrapper = shallowMount(SnippetEditApp, { apolloProvider, - localVue, stubs: { ApolloMutation, FormFooterActions, diff --git a/spec/frontend/snippets/components/snippet_blob_actions_edit_spec.js b/spec/frontend/snippets/components/snippet_blob_actions_edit_spec.js index 2693b26aeae..8174ba5c693 100644 --- a/spec/frontend/snippets/components/snippet_blob_actions_edit_spec.js +++ b/spec/frontend/snippets/components/snippet_blob_actions_edit_spec.js @@ -1,5 +1,6 @@ import { shallowMount } from '@vue/test-utils'; import { times } from 'lodash'; +import { nextTick } from 'vue'; import SnippetBlobActionsEdit from '~/snippets/components/snippet_blob_actions_edit.vue'; import SnippetBlobEdit from '~/snippets/components/snippet_blob_edit.vue'; import { @@ -193,7 +194,7 @@ describe('snippets/components/snippet_blob_actions_edit', () => { it('emits an action when content changes again', async () => { triggerBlobUpdate(0, { content }); - await wrapper.vm.$nextTick(); + await nextTick(); expect(getLastActions()).toEqual([testEntries.updated.diff]); }); diff --git a/spec/frontend/snippets/components/snippet_header_spec.js b/spec/frontend/snippets/components/snippet_header_spec.js index daa9d6345b0..1b9d170556b 100644 --- a/spec/frontend/snippets/components/snippet_header_spec.js +++ b/spec/frontend/snippets/components/snippet_header_spec.js @@ -2,6 +2,7 @@ import { GlButton, GlModal, GlDropdown } from '@gitlab/ui'; import { mount } from '@vue/test-utils'; import { ApolloMutation } from 'vue-apollo'; import MockAdapter from 'axios-mock-adapter'; +import { nextTick } from 'vue'; import { useMockLocationHelper } from 'helpers/mock_window_location_helper'; import waitForPromises from 'helpers/wait_for_promises'; import { Blob, BinaryBlob } from 'jest/blob/components/mock_data'; @@ -245,7 +246,7 @@ describe('Snippet header component', () => { // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // eslint-disable-next-line no-restricted-syntax wrapper.setData({ canCreateSnippet: true }); - await wrapper.vm.$nextTick(); + await nextTick(); expect(findButtonsAsModel()).toEqual( expect.arrayContaining([ @@ -348,33 +349,31 @@ describe('Snippet header component', () => { describe('in case of successful mutation, closes modal and redirects to correct listing', () => { useMockLocationHelper(); - const createDeleteSnippet = (snippetProps = {}) => { + const createDeleteSnippet = async (snippetProps = {}) => { createComponent({ snippetProps, }); wrapper.vm.closeDeleteModal = jest.fn(); wrapper.vm.deleteSnippet(); - return wrapper.vm.$nextTick(); + await nextTick(); }; - it('redirects to dashboard/snippets for personal snippet', () => { - return createDeleteSnippet().then(() => { - expect(wrapper.vm.closeDeleteModal).toHaveBeenCalled(); - expect(window.location.pathname).toBe(`${gon.relative_url_root}dashboard/snippets`); - }); + it('redirects to dashboard/snippets for personal snippet', async () => { + await createDeleteSnippet(); + expect(wrapper.vm.closeDeleteModal).toHaveBeenCalled(); + expect(window.location.pathname).toBe(`${gon.relative_url_root}dashboard/snippets`); }); - it('redirects to project snippets for project snippet', () => { + it('redirects to project snippets for project snippet', async () => { const fullPath = 'foo/bar'; - return createDeleteSnippet({ + await createDeleteSnippet({ project: { fullPath, }, - }).then(() => { - expect(wrapper.vm.closeDeleteModal).toHaveBeenCalled(); - expect(window.location.pathname).toBe(`${fullPath}/-/snippets`); }); + expect(wrapper.vm.closeDeleteModal).toHaveBeenCalled(); + expect(window.location.pathname).toBe(`${fullPath}/-/snippets`); }); }); }); |