diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/frontend/static_site_editor/components/edit_area_spec.js | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) | |
download | gitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/frontend/static_site_editor/components/edit_area_spec.js')
-rw-r--r-- | spec/frontend/static_site_editor/components/edit_area_spec.js | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/spec/frontend/static_site_editor/components/edit_area_spec.js b/spec/frontend/static_site_editor/components/edit_area_spec.js index d7c798e6620..11c5abf1b08 100644 --- a/spec/frontend/static_site_editor/components/edit_area_spec.js +++ b/spec/frontend/static_site_editor/components/edit_area_spec.js @@ -1,6 +1,7 @@ import { shallowMount } from '@vue/test-utils'; import RichContentEditor from '~/vue_shared/components/rich_content_editor/rich_content_editor.vue'; +import { EDITOR_TYPES } from '~/vue_shared/components/rich_content_editor/constants'; import EditArea from '~/static_site_editor/components/edit_area.vue'; import PublishToolbar from '~/static_site_editor/components/publish_toolbar.vue'; @@ -51,7 +52,7 @@ describe('~/static_site_editor/components/edit_area.vue', () => { it('renders rich content editor', () => { expect(findRichContentEditor().exists()).toBe(true); - expect(findRichContentEditor().props('value')).toBe(body); + expect(findRichContentEditor().props('content')).toBe(body); }); it('renders publish toolbar', () => { @@ -75,6 +76,15 @@ describe('~/static_site_editor/components/edit_area.vue', () => { return wrapper.vm.$nextTick(); }); + it('updates parsedSource with new content', () => { + const newContent = 'New content'; + const spySyncParsedSource = jest.spyOn(wrapper.vm.parsedSource, 'sync'); + + findRichContentEditor().vm.$emit('input', newContent); + + expect(spySyncParsedSource).toHaveBeenCalledWith(newContent, true); + }); + it('sets publish toolbar as saveable', () => { expect(findPublishToolbar().props('saveable')).toBe(true); }); @@ -91,4 +101,33 @@ describe('~/static_site_editor/components/edit_area.vue', () => { }); }); }); + + describe('when the mode changes', () => { + const setInitialMode = mode => { + wrapper.setData({ editorMode: mode }); + }; + + afterEach(() => { + setInitialMode(EDITOR_TYPES.wysiwyg); + }); + + it.each` + initialMode | targetMode | resetValue + ${EDITOR_TYPES.wysiwyg} | ${EDITOR_TYPES.markdown} | ${content} + ${EDITOR_TYPES.markdown} | ${EDITOR_TYPES.wysiwyg} | ${body} + `( + 'sets editorMode from $initialMode to $targetMode', + ({ initialMode, targetMode, resetValue }) => { + setInitialMode(initialMode); + + const resetInitialValue = jest.fn(); + + findRichContentEditor().setMethods({ resetInitialValue }); + findRichContentEditor().vm.$emit('modeChange', targetMode); + + expect(resetInitialValue).toHaveBeenCalledWith(resetValue); + expect(wrapper.vm.editorMode).toBe(targetMode); + }, + ); + }); }); |