diff options
Diffstat (limited to 'spec/frontend/lib/utils/confirm_via_gl_modal')
-rw-r--r-- | spec/frontend/lib/utils/confirm_via_gl_modal/confirm_modal_spec.js | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/spec/frontend/lib/utils/confirm_via_gl_modal/confirm_modal_spec.js b/spec/frontend/lib/utils/confirm_via_gl_modal/confirm_modal_spec.js index e06d1384610..d6131b1a1d7 100644 --- a/spec/frontend/lib/utils/confirm_via_gl_modal/confirm_modal_spec.js +++ b/spec/frontend/lib/utils/confirm_via_gl_modal/confirm_modal_spec.js @@ -5,12 +5,23 @@ import ConfirmModal from '~/lib/utils/confirm_via_gl_modal/confirm_modal.vue'; describe('Confirm Modal', () => { let wrapper; let modal; + const SECONDARY_TEXT = 'secondaryText'; + const SECONDARY_VARIANT = 'danger'; - const createComponent = ({ primaryText, primaryVariant, title, hideCancel = false } = {}) => { + const createComponent = ({ + primaryText, + primaryVariant, + secondaryText, + secondaryVariant, + title, + hideCancel = false, + } = {}) => { wrapper = mount(ConfirmModal, { propsData: { primaryText, primaryVariant, + secondaryText, + secondaryVariant, hideCancel, title, }, @@ -65,6 +76,19 @@ describe('Confirm Modal', () => { expect(props.actionCancel).toBeNull(); }); + it('should not show secondary Button when secondary Text is not set', () => { + createComponent(); + const props = findGlModal().props(); + expect(props.actionSecondary).toBeNull(); + }); + + it('should show secondary Button when secondaryText is set', () => { + createComponent({ secondaryText: SECONDARY_TEXT, secondaryVariant: SECONDARY_VARIANT }); + const actionSecondary = findGlModal().props('actionSecondary'); + expect(actionSecondary.text).toEqual(SECONDARY_TEXT); + expect(actionSecondary.attributes.variant).toEqual(SECONDARY_VARIANT); + }); + it('should set the modal title when the `title` prop is set', () => { const title = 'Modal title'; createComponent({ title }); |