diff options
Diffstat (limited to 'spec/frontend/packages_and_registries/settings/project/settings/components/registry_settings_app_spec.js')
-rw-r--r-- | spec/frontend/packages_and_registries/settings/project/settings/components/registry_settings_app_spec.js | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/spec/frontend/packages_and_registries/settings/project/settings/components/registry_settings_app_spec.js b/spec/frontend/packages_and_registries/settings/project/settings/components/registry_settings_app_spec.js index 8266f9bee89..a6c929844b1 100644 --- a/spec/frontend/packages_and_registries/settings/project/settings/components/registry_settings_app_spec.js +++ b/spec/frontend/packages_and_registries/settings/project/settings/components/registry_settings_app_spec.js @@ -1,7 +1,9 @@ import { GlAlert, GlSprintf, GlLink } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import VueApollo from 'vue-apollo'; import createMockApollo from 'helpers/mock_apollo_helper'; +import waitForPromises from 'helpers/wait_for_promises'; import component from '~/packages_and_registries/settings/project/components/registry_settings_app.vue'; import SettingsForm from '~/packages_and_registries/settings/project/components/settings_form.vue'; import { @@ -19,8 +21,6 @@ import { containerExpirationPolicyData, } from '../mock_data'; -const localVue = createLocalVue(); - describe('Registry Settings App', () => { let wrapper; let fakeApollo; @@ -55,17 +55,14 @@ describe('Registry Settings App', () => { }; const mountComponentWithApollo = ({ provide = defaultProvidedValues, resolver } = {}) => { - localVue.use(VueApollo); + Vue.use(VueApollo); const requestHandlers = [[expirationPolicyQuery, resolver]]; fakeApollo = createMockApollo(requestHandlers); mountComponent(provide, { - localVue, apolloProvider: fakeApollo, }); - - return requestHandlers.map((request) => request[1]); }; afterEach(() => { @@ -101,25 +98,25 @@ describe('Registry Settings App', () => { ${'response and changes'} | ${expirationPolicyPayload()} | ${{ ...containerExpirationPolicyData(), nameRegex: '12345' }} | ${true} ${'response and empty'} | ${expirationPolicyPayload()} | ${{}} | ${true} `('$description', async ({ apiResponse, workingCopy, result }) => { - const requests = mountComponentWithApollo({ + mountComponentWithApollo({ provide: { ...defaultProvidedValues, enableHistoricEntries: true }, resolver: jest.fn().mockResolvedValue(apiResponse), }); - await Promise.all(requests); + await waitForPromises(); findSettingsComponent().vm.$emit('input', workingCopy); - await wrapper.vm.$nextTick(); + await waitForPromises(); expect(findSettingsComponent().props('isEdited')).toBe(result); }); }); it('renders the setting form', async () => { - const requests = mountComponentWithApollo({ + mountComponentWithApollo({ resolver: jest.fn().mockResolvedValue(expirationPolicyPayload()), }); - await Promise.all(requests); + await waitForPromises(); expect(findSettingsComponent().exists()).toBe(true); }); @@ -153,11 +150,11 @@ describe('Registry Settings App', () => { }); describe('fetchSettingsError', () => { - beforeEach(() => { - const requests = mountComponentWithApollo({ + beforeEach(async () => { + mountComponentWithApollo({ resolver: jest.fn().mockRejectedValue(new Error('GraphQL error')), }); - return Promise.all(requests); + await waitForPromises(); }); it('the form is hidden', () => { @@ -175,14 +172,14 @@ describe('Registry Settings App', () => { ${true} | ${true} ${false} | ${false} `('is $isShown that the form is shown', async ({ enableHistoricEntries, isShown }) => { - const requests = mountComponentWithApollo({ + mountComponentWithApollo({ provide: { ...defaultProvidedValues, enableHistoricEntries, }, resolver: jest.fn().mockResolvedValue(emptyExpirationPolicyPayload()), }); - await Promise.all(requests); + await waitForPromises(); expect(findSettingsComponent().exists()).toBe(isShown); }); |