diff options
Diffstat (limited to 'spec/frontend/vue_shared/components/markdown/editor_mode_switcher_spec.js')
-rw-r--r-- | spec/frontend/vue_shared/components/markdown/editor_mode_switcher_spec.js | 80 |
1 files changed, 3 insertions, 77 deletions
diff --git a/spec/frontend/vue_shared/components/markdown/editor_mode_switcher_spec.js b/spec/frontend/vue_shared/components/markdown/editor_mode_switcher_spec.js index 712e78458c6..57f54f7e7d3 100644 --- a/spec/frontend/vue_shared/components/markdown/editor_mode_switcher_spec.js +++ b/spec/frontend/vue_shared/components/markdown/editor_mode_switcher_spec.js @@ -1,41 +1,22 @@ import { nextTick } from 'vue'; -import { GlButton, GlLink, GlPopover } from '@gitlab/ui'; +import { GlButton } from '@gitlab/ui'; import { mount } from '@vue/test-utils'; import EditorModeSwitcher from '~/vue_shared/components/markdown/editor_mode_switcher.vue'; -import { counter } from '~/vue_shared/components/markdown/utils'; -import UserCalloutDismisser from '~/vue_shared/components/user_callout_dismisser.vue'; -import { stubComponent } from 'helpers/stub_component'; import { useLocalStorageSpy } from 'helpers/local_storage_helper'; -jest.mock('~/vue_shared/components/markdown/utils', () => ({ - counter: jest.fn().mockReturnValue(0), -})); - describe('vue_shared/component/markdown/editor_mode_switcher', () => { let wrapper; useLocalStorageSpy(); - const createComponent = ({ - value, - userCalloutDismisserSlotProps = { dismiss: jest.fn() }, - } = {}) => { + const createComponent = ({ value } = {}) => { wrapper = mount(EditorModeSwitcher, { propsData: { value, }, - stubs: { - UserCalloutDismisser: stubComponent(UserCalloutDismisser, { - render() { - return this.$scopedSlots.default(userCalloutDismisserSlotProps); - }, - }), - }, }); }; const findSwitcherButton = () => wrapper.findComponent(GlButton); - const findUserCalloutDismisser = () => wrapper.findComponent(UserCalloutDismisser); - const findCalloutPopover = () => wrapper.findComponent(GlPopover); describe.each` value | buttonText @@ -54,62 +35,7 @@ describe('vue_shared/component/markdown/editor_mode_switcher', () => { await nextTick(); findSwitcherButton().vm.$emit('click'); - expect(wrapper.emitted().switch).toEqual([[false]]); - }); - }); - - describe('rich text editor callout', () => { - let dismiss; - - beforeEach(() => { - dismiss = jest.fn(); - createComponent({ value: 'markdown', userCalloutDismisserSlotProps: { dismiss } }); - }); - - it('does not skip the user_callout_dismisser query', () => { - expect(findUserCalloutDismisser().props()).toMatchObject({ - skipQuery: false, - featureName: 'rich_text_editor', - }); - }); - - it('mounts new rich text editor popover', () => { - expect(findCalloutPopover().props()).toMatchObject({ - showCloseButton: '', - triggers: 'manual', - target: 'switch-to-rich-text-editor', - }); - }); - - it('dismisses the callout and emits "switch" event when popover close button is clicked', async () => { - await findCalloutPopover().findComponent(GlLink).vm.$emit('click'); - - expect(wrapper.emitted().switch).toEqual([[true]]); - expect(dismiss).toHaveBeenCalled(); - }); - - it('dismisses the callout when action button is clicked', () => { - findSwitcherButton().vm.$emit('click'); - - expect(dismiss).toHaveBeenCalled(); - }); - - it('does not show the callout if rich text is already enabled', async () => { - await wrapper.setProps({ value: 'richText' }); - - expect(findCalloutPopover().props()).toMatchObject({ - show: false, - }); - }); - - it('does not show the callout if already displayed once on the page', () => { - counter.mockReturnValue(1); - - createComponent({ value: 'markdown' }); - - expect(findCalloutPopover().props()).toMatchObject({ - show: false, - }); + expect(wrapper.emitted().switch).toEqual([[]]); }); }); }); |