diff options
Diffstat (limited to 'spec/frontend/environments/new_environment_spec.js')
-rw-r--r-- | spec/frontend/environments/new_environment_spec.js | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/spec/frontend/environments/new_environment_spec.js b/spec/frontend/environments/new_environment_spec.js index b92c4a688b7..f6d970e02d8 100644 --- a/spec/frontend/environments/new_environment_spec.js +++ b/spec/frontend/environments/new_environment_spec.js @@ -1,3 +1,4 @@ +import { GlLoadingIcon } from '@gitlab/ui'; import MockAdapter from 'axios-mock-adapter'; import { mountExtended } from 'helpers/vue_test_utils_helper'; import waitForPromises from 'helpers/wait_for_promises'; @@ -39,7 +40,9 @@ describe('~/environments/components/new.vue', () => { wrapper.destroy(); }); - const fillForm = async (expected, response) => { + const showsLoading = () => wrapper.find(GlLoadingIcon).exists(); + + const submitForm = async (expected, response) => { mock .onPost(DEFAULT_OPTS.provide.projectEnvironmentsPath, { name: expected.name, @@ -68,10 +71,20 @@ describe('~/environments/components/new.vue', () => { expect(input().element.value).toBe(value); }); + it('shows loader after form is submitted', async () => { + const expected = { name: 'test', url: 'https://google.ca' }; + + expect(showsLoading()).toBe(false); + + await submitForm(expected, [200, { path: '/test' }]); + + expect(showsLoading()).toBe(true); + }); + it('submits the new environment on submit', async () => { const expected = { name: 'test', url: 'https://google.ca' }; - await fillForm(expected, [200, { path: '/test' }]); + await submitForm(expected, [200, { path: '/test' }]); expect(visitUrl).toHaveBeenCalledWith('/test'); }); @@ -79,8 +92,9 @@ describe('~/environments/components/new.vue', () => { it('shows errors on error', async () => { const expected = { name: 'test', url: 'https://google.ca' }; - await fillForm(expected, [400, { message: ['name taken'] }]); + await submitForm(expected, [400, { message: ['name taken'] }]); expect(createFlash).toHaveBeenCalledWith({ message: 'name taken' }); + expect(showsLoading()).toBe(false); }); }); |