Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-15 12:09:03 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-15 12:09:03 +0300
commit73ff43129b98d433923d144fccd2e47c33c3b091 (patch)
tree8dc7ffe90e38bb0699c3ff48f1d89b1b354e8ef3 /spec/frontend/vue_shared/components/blob_viewers
parent17e561ffb82d134ccdee8dfb505d9cba7c311a4c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/vue_shared/components/blob_viewers')
-rw-r--r--spec/frontend/vue_shared/components/blob_viewers/simple_viewer_spec.js44
1 files changed, 33 insertions, 11 deletions
diff --git a/spec/frontend/vue_shared/components/blob_viewers/simple_viewer_spec.js b/spec/frontend/vue_shared/components/blob_viewers/simple_viewer_spec.js
index 92a326efd83..46d4edad891 100644
--- a/spec/frontend/vue_shared/components/blob_viewers/simple_viewer_spec.js
+++ b/spec/frontend/vue_shared/components/blob_viewers/simple_viewer_spec.js
@@ -1,4 +1,5 @@
import { shallowMount } from '@vue/test-utils';
+import waitForPromises from 'helpers/wait_for_promises';
import { HIGHLIGHT_CLASS_NAME } from '~/vue_shared/components/blob_viewers/constants';
import SimpleViewer from '~/vue_shared/components/blob_viewers/simple_viewer.vue';
import EditorLite from '~/vue_shared/components/editor_lite.vue';
@@ -8,10 +9,17 @@ describe('Blob Simple Viewer component', () => {
const contentMock = `<span id="LC1">First</span>\n<span id="LC2">Second</span>\n<span id="LC3">Third</span>`;
const blobHash = 'foo-bar';
- function createComponent(content = contentMock, isRawContent = false) {
+ function createComponent(
+ content = contentMock,
+ isRawContent = false,
+ isRefactorFlagEnabled = false,
+ ) {
wrapper = shallowMount(SimpleViewer, {
provide: {
blobHash,
+ glFeatures: {
+ refactorBlobViewer: isRefactorFlagEnabled,
+ },
},
propsData: {
content,
@@ -87,17 +95,31 @@ describe('Blob Simple Viewer component', () => {
});
});
- describe('raw content', () => {
+ describe('Vue refactoring to use Source Editor', () => {
const findEditorLite = () => wrapper.find(EditorLite);
- const isRawContent = true;
- it('uses the Editor Lite component in readonly mode when viewing raw content', () => {
- createComponent('raw content', isRawContent);
-
- expect(findEditorLite().exists()).toBe(true);
- expect(findEditorLite().props('value')).toBe('raw content');
- expect(findEditorLite().props('fileName')).toBe('test.js');
- expect(findEditorLite().props('editorOptions')).toEqual({ readOnly: true });
- });
+ it.each`
+ doesRender | condition | isRawContent | isRefactorFlagEnabled
+ ${'Does not'} | ${'rawContent is not specified'} | ${false} | ${true}
+ ${'Does not'} | ${'feature flag is disabled is not specified'} | ${true} | ${false}
+ ${'Does not'} | ${'both, the FF and rawContent are not specified'} | ${false} | ${false}
+ ${'Does'} | ${'both, the FF and rawContent are specified'} | ${true} | ${true}
+ `(
+ '$doesRender render Editor Lite component in readonly mode when $condition',
+ async ({ isRawContent, isRefactorFlagEnabled } = {}) => {
+ createComponent('raw content', isRawContent, isRefactorFlagEnabled);
+ await waitForPromises();
+
+ if (isRawContent && isRefactorFlagEnabled) {
+ expect(findEditorLite().exists()).toBe(true);
+
+ expect(findEditorLite().props('value')).toBe('raw content');
+ expect(findEditorLite().props('fileName')).toBe('test.js');
+ expect(findEditorLite().props('editorOptions')).toEqual({ readOnly: true });
+ } else {
+ expect(findEditorLite().exists()).toBe(false);
+ }
+ },
+ );
});
});