diff options
Diffstat (limited to 'spec/frontend/integrations/edit/components/confirmation_modal_spec.js')
-rw-r--r-- | spec/frontend/integrations/edit/components/confirmation_modal_spec.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/frontend/integrations/edit/components/confirmation_modal_spec.js b/spec/frontend/integrations/edit/components/confirmation_modal_spec.js new file mode 100644 index 00000000000..02f311f579f --- /dev/null +++ b/spec/frontend/integrations/edit/components/confirmation_modal_spec.js @@ -0,0 +1,51 @@ +import { shallowMount } from '@vue/test-utils'; +import { GlModal } from '@gitlab/ui'; +import { createStore } from '~/integrations/edit/store'; + +import ConfirmationModal from '~/integrations/edit/components/confirmation_modal.vue'; + +describe('ConfirmationModal', () => { + let wrapper; + + const createComponent = () => { + wrapper = shallowMount(ConfirmationModal, { + store: createStore(), + }); + }; + + afterEach(() => { + if (wrapper) { + wrapper.destroy(); + wrapper = null; + } + }); + + const findGlModal = () => wrapper.find(GlModal); + + describe('template', () => { + beforeEach(() => { + createComponent(); + }); + + it('renders GlModal with correct copy', () => { + expect(findGlModal().exists()).toBe(true); + expect(findGlModal().attributes('title')).toBe('Save settings?'); + expect(findGlModal().text()).toContain( + 'Saving will update the default settings for all projects that are not using custom settings.', + ); + expect(findGlModal().text()).toContain( + 'Projects using custom settings will not be impacted unless the project owner chooses to use instance-level defaults.', + ); + }); + + it('emits `submit` event when `primary` event is emitted on GlModal', async () => { + expect(wrapper.emitted().submit).toBeUndefined(); + + findGlModal().vm.$emit('primary'); + + await wrapper.vm.$nextTick(); + + expect(wrapper.emitted().submit).toHaveLength(1); + }); + }); +}); |