diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-23 15:07:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-23 15:07:27 +0300 |
commit | 3e68d3848770b492d314f8e2967c37f7fdd5d143 (patch) | |
tree | 01bd69a759c55ddf4ea1e5549a253cb0fd564854 /spec/frontend_integration/content_editor | |
parent | 52192e0f19ca790dc9f44bc45730434100f83d90 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend_integration/content_editor')
-rw-r--r-- | spec/frontend_integration/content_editor/content_editor_integration_spec.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/spec/frontend_integration/content_editor/content_editor_integration_spec.js b/spec/frontend_integration/content_editor/content_editor_integration_spec.js new file mode 100644 index 00000000000..1b45c0d43a3 --- /dev/null +++ b/spec/frontend_integration/content_editor/content_editor_integration_spec.js @@ -0,0 +1,63 @@ +import { nextTick } from 'vue'; +import { mountExtended } from 'helpers/vue_test_utils_helper'; +import { ContentEditor } from '~/content_editor'; + +/** + * This spec exercises some workflows in the Content Editor without mocking + * any component. + * + */ +describe('content_editor', () => { + let wrapper; + let renderMarkdown; + let contentEditorService; + + const buildWrapper = () => { + renderMarkdown = jest.fn(); + wrapper = mountExtended(ContentEditor, { + propsData: { + renderMarkdown, + uploadsPath: '/', + }, + listeners: { + initialized(contentEditor) { + contentEditorService = contentEditor; + }, + }, + }); + }; + + describe('when loading initial content', () => { + describe('when the initial content is empty', () => { + it('still hides the loading indicator', async () => { + buildWrapper(); + + renderMarkdown.mockResolvedValue(''); + + await contentEditorService.setSerializedContent(''); + await nextTick(); + + expect(wrapper.findByTestId('content-editor-loading-indicator').exists()).toBe(false); + }); + }); + + describe('when the initial content is not empty', () => { + const initialContent = '<p><strong>bold text</strong></p>'; + beforeEach(async () => { + buildWrapper(); + + renderMarkdown.mockResolvedValue(initialContent); + + await contentEditorService.setSerializedContent('**bold text**'); + await nextTick(); + }); + it('hides the loading indicator', async () => { + expect(wrapper.findByTestId('content-editor-loading-indicator').exists()).toBe(false); + }); + + it('displays the initial content', async () => { + expect(wrapper.html()).toContain(initialContent); + }); + }); + }); +}); |