diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-13 21:08:59 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-13 21:08:59 +0000 |
commit | d466ee5042520ad078fe050cb078d81dc2ebe196 (patch) | |
tree | 5648eb1aee8aeff5b5c5ff4669a184fd7676f778 /spec/frontend/ide/components | |
parent | 6a9d7c009e4e5975a89bcc3e458da4b3ec484bd1 (diff) | |
download | gitlab-ce-d466ee5042520ad078fe050cb078d81dc2ebe196.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ide/components')
-rw-r--r-- | spec/frontend/ide/components/error_message_spec.js | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/spec/frontend/ide/components/error_message_spec.js b/spec/frontend/ide/components/error_message_spec.js index 1de496ba3f8..3a4dcc5873d 100644 --- a/spec/frontend/ide/components/error_message_spec.js +++ b/spec/frontend/ide/components/error_message_spec.js @@ -1,4 +1,4 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { mount, createLocalVue } from '@vue/test-utils'; import Vuex from 'vuex'; import { GlLoadingIcon } from '@gitlab/ui'; import ErrorMessage from '~/ide/components/error_message.vue'; @@ -15,7 +15,7 @@ describe('IDE error message component', () => { actions: { setErrorMessage: setErrorMessageMock }, }); - wrapper = shallowMount(ErrorMessage, { + wrapper = mount(ErrorMessage, { propsData: { message: { text: 'some text', @@ -38,15 +38,18 @@ describe('IDE error message component', () => { wrapper = null; }); + const findDismissButton = () => wrapper.find('button[aria-label=Dismiss]'); + const findActionButton = () => wrapper.find('button.gl-alert-action'); + it('renders error message', () => { const text = 'error message'; createComponent({ text }); expect(wrapper.text()).toContain(text); }); - it('clears error message on click', () => { + it('clears error message on dismiss click', () => { createComponent(); - wrapper.trigger('click'); + findDismissButton().trigger('click'); expect(setErrorMessageMock).toHaveBeenCalledWith(expect.any(Object), null, undefined); }); @@ -68,29 +71,27 @@ describe('IDE error message component', () => { }); it('renders action button', () => { - const button = wrapper.find('button'); + const button = findActionButton(); expect(button.exists()).toBe(true); expect(button.text()).toContain(message.actionText); }); - it('does not clear error message on click', () => { - wrapper.trigger('click'); - - expect(setErrorMessageMock).not.toHaveBeenCalled(); + it('does not show dismiss button', () => { + expect(findDismissButton().exists()).toBe(false); }); it('dispatches action', () => { - wrapper.find('button').trigger('click'); + findActionButton().trigger('click'); expect(actionMock).toHaveBeenCalledWith(message.actionPayload); }); it('does not dispatch action when already loading', () => { - wrapper.find('button').trigger('click'); + findActionButton().trigger('click'); actionMock.mockReset(); return wrapper.vm.$nextTick(() => { - wrapper.find('button').trigger('click'); + findActionButton().trigger('click'); return wrapper.vm.$nextTick().then(() => { expect(actionMock).not.toHaveBeenCalled(); @@ -106,7 +107,7 @@ describe('IDE error message component', () => { resolveAction = resolve; }), ); - wrapper.find('button').trigger('click'); + findActionButton().trigger('click'); return wrapper.vm.$nextTick(() => { expect(wrapper.find(GlLoadingIcon).isVisible()).toBe(true); @@ -115,7 +116,7 @@ describe('IDE error message component', () => { }); it('hides loading icon when operation finishes', () => { - wrapper.find('button').trigger('click'); + findActionButton().trigger('click'); return actionMock() .then(() => wrapper.vm.$nextTick()) .then(() => { |