diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-15 18:09:09 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-15 18:09:09 +0000 |
commit | da1962d9ac710f95d350d2645c87f5a663123cf2 (patch) | |
tree | 1725ade126a9b4ae0148cd100cee94c44f9ce9f3 /spec/frontend/projects/components/remove_modal_spec.js | |
parent | e69e3f1eb695b4e852c56e7ddf8c52915ae2631b (diff) | |
download | gitlab-ce-da1962d9ac710f95d350d2645c87f5a663123cf2.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/projects/components/remove_modal_spec.js')
-rw-r--r-- | spec/frontend/projects/components/remove_modal_spec.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/frontend/projects/components/remove_modal_spec.js b/spec/frontend/projects/components/remove_modal_spec.js new file mode 100644 index 00000000000..339aee65b99 --- /dev/null +++ b/spec/frontend/projects/components/remove_modal_spec.js @@ -0,0 +1,62 @@ +import { shallowMount } from '@vue/test-utils'; +import { GlButton, GlModal } from '@gitlab/ui'; +import ProjectRemoveModal from '~/projects/components/remove_modal.vue'; + +describe('Project remove modal', () => { + let wrapper; + + const findFormElement = () => wrapper.find('form').element; + const findConfirmButton = () => wrapper.find(GlModal).find(GlButton); + + const defaultProps = { + formPath: 'some/path', + confirmPhrase: 'foo', + warningMessage: 'This can lead to data loss.', + }; + + const createComponent = (data = {}) => { + wrapper = shallowMount(ProjectRemoveModal, { + propsData: defaultProps, + data: () => data, + stubs: { + GlButton, + GlModal, + }, + }); + }; + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + describe('initialized', () => { + beforeEach(() => { + createComponent(); + }); + + it('matches the snapshot', () => { + expect(wrapper.element).toMatchSnapshot(); + }); + }); + + describe('user input matches the confirmPhrase', () => { + beforeEach(() => { + createComponent({ userInput: defaultProps.confirmPhrase }); + }); + + it('the confirm button is not dislabled', () => { + expect(findConfirmButton().attributes('disabled')).toBe(undefined); + }); + + describe('and when the confirmation button is clicked', () => { + beforeEach(() => { + findConfirmButton().vm.$emit('click'); + }); + + it('submits the form element', () => { + expect(findFormElement().submit).toHaveBeenCalled(); + }); + }); + }); +}); |