diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-08 21:13:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-08 21:13:15 +0300 |
commit | 3a563d7c1e15023f205d2a357e5d8a38a3b53ecc (patch) | |
tree | b7979f23104af9ed6d0ef077ce9964ba5d7ad65e /spec/frontend/vue_shared | |
parent | dcc56fe601580b5d8f6c3da32550c6523f2baff3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/vue_shared')
-rw-r--r-- | spec/frontend/vue_shared/components/markdown/markdown_editor_spec.js | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/spec/frontend/vue_shared/components/markdown/markdown_editor_spec.js b/spec/frontend/vue_shared/components/markdown/markdown_editor_spec.js index d32e148ef79..26a74036b10 100644 --- a/spec/frontend/vue_shared/components/markdown/markdown_editor_spec.js +++ b/spec/frontend/vue_shared/components/markdown/markdown_editor_spec.js @@ -3,7 +3,12 @@ import Autosize from 'autosize'; import MockAdapter from 'axios-mock-adapter'; import { nextTick } from 'vue'; import { mountExtended } from 'helpers/vue_test_utils_helper'; -import { EDITING_MODE_MARKDOWN_FIELD, EDITING_MODE_CONTENT_EDITOR } from '~/vue_shared/constants'; +import { + EDITING_MODE_MARKDOWN_FIELD, + EDITING_MODE_CONTENT_EDITOR, + CLEAR_AUTOSAVE_ENTRY_EVENT, +} from '~/vue_shared/constants'; +import markdownEditorEventHub from '~/vue_shared/components/markdown/eventhub'; import MarkdownEditor from '~/vue_shared/components/markdown/markdown_editor.vue'; import ContentEditor from '~/content_editor/components/content_editor.vue'; import BubbleMenu from '~/content_editor/components/bubble_menus/bubble_menu.vue'; @@ -251,6 +256,38 @@ describe('vue_shared/component/markdown/markdown_editor', () => { expect(localStorage.setItem).not.toHaveBeenCalled(); }); + + describe('clear local storage event handler', () => { + it('does not clear the local storage if the autosave key is not defined', async () => { + buildWrapper(); + + await waitForPromises(); + + markdownEditorEventHub.$emit(CLEAR_AUTOSAVE_ENTRY_EVENT, 'issue/1234'); + + expect(localStorage.removeItem).not.toHaveBeenCalled(); + }); + + it('does not clear the local storage if the event autosave key does not match', async () => { + buildWrapper({ propsData: { autosaveKey: 'issue/1234' } }); + + await waitForPromises(); + + markdownEditorEventHub.$emit(CLEAR_AUTOSAVE_ENTRY_EVENT, 'issue/1235'); + + expect(localStorage.removeItem).not.toHaveBeenCalled(); + }); + + it('clears the local storage if the event autosave key matches', async () => { + buildWrapper({ propsData: { autosaveKey: 'issue/1234' } }); + + await waitForPromises(); + + markdownEditorEventHub.$emit(CLEAR_AUTOSAVE_ENTRY_EVENT, 'issue/1234'); + + expect(localStorage.removeItem).toHaveBeenCalledWith('autosave/issue/1234'); + }); + }); }); it('renders markdown field textarea', () => { |