diff options
Diffstat (limited to 'spec/frontend/editor')
-rw-r--r-- | spec/frontend/editor/source_editor_ci_schema_ext_spec.js (renamed from spec/frontend/editor/editor_ci_schema_ext_spec.js) | 6 | ||||
-rw-r--r-- | spec/frontend/editor/source_editor_extension_base_spec.js (renamed from spec/frontend/editor/editor_lite_extension_base_spec.js) | 62 | ||||
-rw-r--r-- | spec/frontend/editor/source_editor_markdown_ext_spec.js (renamed from spec/frontend/editor/editor_markdown_ext_spec.js) | 8 | ||||
-rw-r--r-- | spec/frontend/editor/source_editor_spec.js (renamed from spec/frontend/editor/editor_lite_spec.js) | 36 |
4 files changed, 56 insertions, 56 deletions
diff --git a/spec/frontend/editor/editor_ci_schema_ext_spec.js b/spec/frontend/editor/source_editor_ci_schema_ext_spec.js index 2f0ecfb151e..07ac080fe08 100644 --- a/spec/frontend/editor/editor_ci_schema_ext_spec.js +++ b/spec/frontend/editor/source_editor_ci_schema_ext_spec.js @@ -1,8 +1,8 @@ import { languages } from 'monaco-editor'; import { TEST_HOST } from 'helpers/test_constants'; import { EXTENSION_CI_SCHEMA_FILE_NAME_MATCH } from '~/editor/constants'; -import EditorLite from '~/editor/editor_lite'; -import { CiSchemaExtension } from '~/editor/extensions/editor_ci_schema_ext'; +import { CiSchemaExtension } from '~/editor/extensions/source_editor_ci_schema_ext'; +import SourceEditor from '~/editor/source_editor'; const mockRef = 'AABBCCDD'; @@ -17,7 +17,7 @@ describe('~/editor/editor_ci_config_ext', () => { const createMockEditor = ({ blobPath = defaultBlobPath } = {}) => { setFixtures('<div id="editor"></div>'); editorEl = document.getElementById('editor'); - editor = new EditorLite(); + editor = new SourceEditor(); instance = editor.createInstance({ el: editorEl, blobPath, diff --git a/spec/frontend/editor/editor_lite_extension_base_spec.js b/spec/frontend/editor/source_editor_extension_base_spec.js index 59e1b8968eb..352db9d0d51 100644 --- a/spec/frontend/editor/editor_lite_extension_base_spec.js +++ b/spec/frontend/editor/source_editor_extension_base_spec.js @@ -5,7 +5,7 @@ import { EDITOR_TYPE_CODE, EDITOR_TYPE_DIFF, } from '~/editor/constants'; -import { EditorLiteExtension } from '~/editor/extensions/editor_lite_extension_base'; +import { SourceEditorExtension } from '~/editor/extensions/source_editor_extension_base'; jest.mock('~/helpers/startup_css_helper', () => { return { @@ -22,7 +22,7 @@ jest.mock('~/helpers/startup_css_helper', () => { }; }); -describe('The basis for an Editor Lite extension', () => { +describe('The basis for an Source Editor extension', () => { const defaultLine = 3; let ext; let event; @@ -63,7 +63,7 @@ describe('The basis for an Editor Lite extension', () => { const instance = { layout: jest.fn(), }; - ext = new EditorLiteExtension({ instance }); + ext = new SourceEditorExtension({ instance }); expect(instance.layout).not.toHaveBeenCalled(); // We're waiting for the waitForCSSLoaded mock to kick in @@ -79,7 +79,7 @@ describe('The basis for an Editor Lite extension', () => { ${'does not fail if both instance and the options are omitted'} | ${undefined} | ${undefined} ${'throws if only options are passed'} | ${undefined} | ${defaultOptions} `('$description', ({ instance, options } = {}) => { - EditorLiteExtension.deferRerender = jest.fn(); + SourceEditorExtension.deferRerender = jest.fn(); const originalInstance = { ...instance }; if (instance) { @@ -88,54 +88,54 @@ describe('The basis for an Editor Lite extension', () => { expect(instance[prop]).toBeUndefined(); }); // Both instance and options are passed - ext = new EditorLiteExtension({ instance, ...options }); + ext = new SourceEditorExtension({ instance, ...options }); Object.entries(options).forEach(([prop, value]) => { expect(ext[prop]).toBeUndefined(); expect(instance[prop]).toBe(value); }); } else { - ext = new EditorLiteExtension({ instance }); + ext = new SourceEditorExtension({ instance }); expect(instance).toEqual(originalInstance); } } else if (options) { // Options are passed without instance expect(() => { - ext = new EditorLiteExtension({ ...options }); + ext = new SourceEditorExtension({ ...options }); }).toThrow(ERROR_INSTANCE_REQUIRED_FOR_EXTENSION); } else { // Neither options nor instance are passed expect(() => { - ext = new EditorLiteExtension(); + ext = new SourceEditorExtension(); }).not.toThrow(); } }); it('initializes the line highlighting', () => { - EditorLiteExtension.deferRerender = jest.fn(); - const spy = jest.spyOn(EditorLiteExtension, 'highlightLines'); - ext = new EditorLiteExtension({ instance: {} }); + SourceEditorExtension.deferRerender = jest.fn(); + const spy = jest.spyOn(SourceEditorExtension, 'highlightLines'); + ext = new SourceEditorExtension({ instance: {} }); expect(spy).toHaveBeenCalled(); }); it('sets up the line linking for code instance', () => { - EditorLiteExtension.deferRerender = jest.fn(); - const spy = jest.spyOn(EditorLiteExtension, 'setupLineLinking'); + SourceEditorExtension.deferRerender = jest.fn(); + const spy = jest.spyOn(SourceEditorExtension, 'setupLineLinking'); const instance = { getEditorType: jest.fn().mockReturnValue(EDITOR_TYPE_CODE), onMouseMove: jest.fn(), onMouseDown: jest.fn(), }; - ext = new EditorLiteExtension({ instance }); + ext = new SourceEditorExtension({ instance }); expect(spy).toHaveBeenCalledWith(instance); }); it('does not set up the line linking for diff instance', () => { - EditorLiteExtension.deferRerender = jest.fn(); - const spy = jest.spyOn(EditorLiteExtension, 'setupLineLinking'); + SourceEditorExtension.deferRerender = jest.fn(); + const spy = jest.spyOn(SourceEditorExtension, 'setupLineLinking'); const instance = { getEditorType: jest.fn().mockReturnValue(EDITOR_TYPE_DIFF), }; - ext = new EditorLiteExtension({ instance }); + ext = new SourceEditorExtension({ instance }); expect(spy).not.toHaveBeenCalled(); }); }); @@ -172,7 +172,7 @@ describe('The basis for an Editor Lite extension', () => { ${'does not highlight if hash is incomplete 2'} | ${'#L-'} | ${false} | ${null} `('$desc', ({ hash, shouldReveal, expectedRange } = {}) => { window.location.hash = hash; - EditorLiteExtension.highlightLines(instance); + SourceEditorExtension.highlightLines(instance); if (!shouldReveal) { expect(revealSpy).not.toHaveBeenCalled(); expect(decorationsSpy).not.toHaveBeenCalled(); @@ -194,7 +194,7 @@ describe('The basis for an Editor Lite extension', () => { decorationsSpy.mockReturnValue('foo'); window.location.hash = '#L10'; expect(instance.lineDecorations).toBeUndefined(); - EditorLiteExtension.highlightLines(instance); + SourceEditorExtension.highlightLines(instance); expect(instance.lineDecorations).toBe('foo'); }); }); @@ -208,7 +208,7 @@ describe('The basis for an Editor Lite extension', () => { }; beforeEach(() => { - EditorLiteExtension.onMouseMoveHandler(event); // generate the anchor + SourceEditorExtension.onMouseMoveHandler(event); // generate the anchor }); it.each` @@ -216,7 +216,7 @@ describe('The basis for an Editor Lite extension', () => { ${'onMouseMove'} | ${instance.onMouseMove} ${'onMouseDown'} | ${instance.onMouseDown} `('sets up the $desc listener', ({ spy } = {}) => { - EditorLiteExtension.setupLineLinking(instance); + SourceEditorExtension.setupLineLinking(instance); expect(spy).toHaveBeenCalled(); }); @@ -230,7 +230,7 @@ describe('The basis for an Editor Lite extension', () => { fn(event); }); - EditorLiteExtension.setupLineLinking(instance); + SourceEditorExtension.setupLineLinking(instance); if (shouldRemove) { expect(instance.deltaDecorations).toHaveBeenCalledWith(instance.lineDecorations, []); } else { @@ -241,7 +241,7 @@ describe('The basis for an Editor Lite extension', () => { describe('onMouseMoveHandler', () => { it('stops propagation for contextmenu event on the generated anchor', () => { - EditorLiteExtension.onMouseMoveHandler(event); + SourceEditorExtension.onMouseMoveHandler(event); const anchor = findLine(defaultLine).querySelector('a'); const contextMenuEvent = new Event('contextmenu'); @@ -253,27 +253,27 @@ describe('The basis for an Editor Lite extension', () => { it('creates an anchor if it does not exist yet', () => { expect(findLine(defaultLine).querySelector('a')).toBe(null); - EditorLiteExtension.onMouseMoveHandler(event); + SourceEditorExtension.onMouseMoveHandler(event); expect(findLine(defaultLine).querySelector('a')).not.toBe(null); }); it('does not create a new anchor if it exists', () => { - EditorLiteExtension.onMouseMoveHandler(event); + SourceEditorExtension.onMouseMoveHandler(event); expect(findLine(defaultLine).querySelector('a')).not.toBe(null); - EditorLiteExtension.createAnchor = jest.fn(); - EditorLiteExtension.onMouseMoveHandler(event); - expect(EditorLiteExtension.createAnchor).not.toHaveBeenCalled(); + SourceEditorExtension.createAnchor = jest.fn(); + SourceEditorExtension.onMouseMoveHandler(event); + expect(SourceEditorExtension.createAnchor).not.toHaveBeenCalled(); expect(findLine(defaultLine).querySelectorAll('a')).toHaveLength(1); }); it('does not create a link if the event is triggered on a wrong node', () => { setFixtures('<div class="wrong-class">3</div>'); - EditorLiteExtension.createAnchor = jest.fn(); + SourceEditorExtension.createAnchor = jest.fn(); const wrongEvent = generateEventMock({ el: document.querySelector('.wrong-class') }); - EditorLiteExtension.onMouseMoveHandler(wrongEvent); - expect(EditorLiteExtension.createAnchor).not.toHaveBeenCalled(); + SourceEditorExtension.onMouseMoveHandler(wrongEvent); + expect(SourceEditorExtension.createAnchor).not.toHaveBeenCalled(); }); }); }); diff --git a/spec/frontend/editor/editor_markdown_ext_spec.js b/spec/frontend/editor/source_editor_markdown_ext_spec.js index 3f64dcfd7a0..943e21250b4 100644 --- a/spec/frontend/editor/editor_markdown_ext_spec.js +++ b/spec/frontend/editor/source_editor_markdown_ext_spec.js @@ -1,8 +1,8 @@ import { Range, Position } from 'monaco-editor'; -import EditorLite from '~/editor/editor_lite'; -import { EditorMarkdownExtension } from '~/editor/extensions/editor_markdown_ext'; +import { EditorMarkdownExtension } from '~/editor/extensions/source_editor_markdown_ext'; +import SourceEditor from '~/editor/source_editor'; -describe('Markdown Extension for Editor Lite', () => { +describe('Markdown Extension for Source Editor', () => { let editor; let instance; let editorEl; @@ -25,7 +25,7 @@ describe('Markdown Extension for Editor Lite', () => { beforeEach(() => { setFixtures('<div id="editor" data-editor-loading></div>'); editorEl = document.getElementById('editor'); - editor = new EditorLite(); + editor = new SourceEditor(); instance = editor.createInstance({ el: editorEl, blobPath: filePath, diff --git a/spec/frontend/editor/editor_lite_spec.js b/spec/frontend/editor/source_editor_spec.js index 815457e012f..d87d373c952 100644 --- a/spec/frontend/editor/editor_lite_spec.js +++ b/spec/frontend/editor/source_editor_spec.js @@ -2,12 +2,12 @@ import { editor as monacoEditor, languages as monacoLanguages } from 'monaco-editor'; import waitForPromises from 'helpers/wait_for_promises'; import { - EDITOR_LITE_INSTANCE_ERROR_NO_EL, + SOURCE_EDITOR_INSTANCE_ERROR_NO_EL, URI_PREFIX, EDITOR_READY_EVENT, } from '~/editor/constants'; -import EditorLite from '~/editor/editor_lite'; -import { EditorLiteExtension } from '~/editor/extensions/editor_lite_extension_base'; +import { SourceEditorExtension } from '~/editor/extensions/source_editor_extension_base'; +import SourceEditor from '~/editor/source_editor'; import { DEFAULT_THEME, themes } from '~/ide/lib/themes'; import { joinPaths } from '~/lib/utils/url_utility'; @@ -25,7 +25,7 @@ describe('Base editor', () => { setFixtures('<div id="editor" data-editor-loading></div>'); editorEl = document.getElementById('editor'); defaultArguments = { el: editorEl, blobPath, blobContent, blobGlobalId }; - editor = new EditorLite(); + editor = new SourceEditor(); }); afterEach(() => { @@ -49,7 +49,7 @@ describe('Base editor', () => { expect(editorEl.dataset.editorLoading).toBeUndefined(); }); - describe('instance of the Editor Lite', () => { + describe('instance of the Source Editor', () => { let modelSpy; let instanceSpy; const setModel = jest.fn(); @@ -58,7 +58,7 @@ describe('Base editor', () => { modelSpy = jest.spyOn(monacoEditor, 'createModel').mockImplementation(() => res); }; const mockDecorateInstance = (decorations = {}) => { - jest.spyOn(EditorLite, 'convertMonacoToELInstance').mockImplementation((inst) => { + jest.spyOn(SourceEditor, 'convertMonacoToELInstance').mockImplementation((inst) => { return Object.assign(inst, decorations); }); }; @@ -76,11 +76,11 @@ describe('Base editor', () => { mockDecorateInstance(); expect(() => { editor.createInstance(); - }).toThrow(EDITOR_LITE_INSTANCE_ERROR_NO_EL); + }).toThrow(SOURCE_EDITOR_INSTANCE_ERROR_NO_EL); expect(modelSpy).not.toHaveBeenCalled(); expect(instanceSpy).not.toHaveBeenCalled(); - expect(EditorLite.convertMonacoToELInstance).not.toHaveBeenCalled(); + expect(SourceEditor.convertMonacoToELInstance).not.toHaveBeenCalled(); }); it('creates model to be supplied to Monaco editor', () => { @@ -246,7 +246,7 @@ describe('Base editor', () => { let editorEl2; let inst1; let inst2; - const readOnlyIndex = '68'; // readOnly option has the internal index of 68 in the editor's options + const readOnlyIndex = '78'; // readOnly option has the internal index of 78 in the editor's options beforeEach(() => { setFixtures('<div id="editor1"></div><div id="editor2"></div>'); @@ -261,7 +261,7 @@ describe('Base editor', () => { blobPath, }; - editor = new EditorLite(); + editor = new SourceEditor(); instanceSpy = jest.spyOn(monacoEditor, 'create'); }); @@ -304,7 +304,7 @@ describe('Base editor', () => { }); it('shares global editor options among all instances', () => { - editor = new EditorLite({ + editor = new SourceEditor({ readOnly: true, }); @@ -316,7 +316,7 @@ describe('Base editor', () => { }); it('allows overriding editor options on the instance level', () => { - editor = new EditorLite({ + editor = new SourceEditor({ readOnly: true, }); inst1 = editor.createInstance({ @@ -410,7 +410,7 @@ describe('Base editor', () => { return WithStaticMethod.computeBoo(this.base); } } - class WithStaticMethodExtended extends EditorLiteExtension { + class WithStaticMethodExtended extends SourceEditorExtension { static computeBoo(a) { return a + 1; } @@ -546,7 +546,7 @@ describe('Base editor', () => { beforeEach(() => { editorExtensionSpy = jest - .spyOn(EditorLite, 'pushToImportsArray') + .spyOn(SourceEditor, 'pushToImportsArray') .mockImplementation((arr) => { arr.push( Promise.resolve({ @@ -593,7 +593,7 @@ describe('Base editor', () => { const useSpy = jest.fn().mockImplementation(() => { calls.push('use'); }); - jest.spyOn(EditorLite, 'convertMonacoToELInstance').mockImplementation((inst) => { + jest.spyOn(SourceEditor, 'convertMonacoToELInstance').mockImplementation((inst) => { const decoratedInstance = inst; decoratedInstance.use = useSpy; return decoratedInstance; @@ -664,7 +664,7 @@ describe('Base editor', () => { it('sets default syntax highlighting theme', () => { const expectedTheme = themes.find((t) => t.name === DEFAULT_THEME); - editor = new EditorLite(); + editor = new SourceEditor(); expect(themeDefineSpy).toHaveBeenCalledWith(DEFAULT_THEME, expectedTheme.data); expect(themeSetSpy).toHaveBeenCalledWith(DEFAULT_THEME); @@ -676,7 +676,7 @@ describe('Base editor', () => { expect(expectedTheme.name).not.toBe(DEFAULT_THEME); window.gon.user_color_scheme = expectedTheme.name; - editor = new EditorLite(); + editor = new SourceEditor(); expect(themeDefineSpy).toHaveBeenCalledWith(expectedTheme.name, expectedTheme.data); expect(themeSetSpy).toHaveBeenCalledWith(expectedTheme.name); @@ -687,7 +687,7 @@ describe('Base editor', () => { const nonExistentTheme = { name }; window.gon.user_color_scheme = nonExistentTheme.name; - editor = new EditorLite(); + editor = new SourceEditor(); expect(themeDefineSpy).not.toHaveBeenCalled(); expect(themeSetSpy).toHaveBeenCalledWith(DEFAULT_THEME); |