From a09983ae35713f5a2bbb100981116d31ce99826e Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 20 Jul 2020 12:26:25 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-2-stable-ee --- .../components/edit_area_spec.js | 41 +++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'spec/frontend/static_site_editor/components/edit_area_spec.js') 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); + }, + ); + }); }); -- cgit v1.2.1