diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/frontend/pipeline_editor/components/editor/text_editor_spec.js | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/frontend/pipeline_editor/components/editor/text_editor_spec.js')
-rw-r--r-- | spec/frontend/pipeline_editor/components/editor/text_editor_spec.js | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/spec/frontend/pipeline_editor/components/editor/text_editor_spec.js b/spec/frontend/pipeline_editor/components/editor/text_editor_spec.js index 7a5b01fb04a..6f9245e39aa 100644 --- a/spec/frontend/pipeline_editor/components/editor/text_editor_spec.js +++ b/spec/frontend/pipeline_editor/components/editor/text_editor_spec.js @@ -9,6 +9,7 @@ import { mockCommitSha, mockProjectPath, mockProjectNamespace, + mockDefaultBranch, } from '../../mock_data'; describe('Pipeline Editor | Text editor component', () => { @@ -32,12 +33,14 @@ describe('Pipeline Editor | Text editor component', () => { }, }; - const createComponent = (opts = {}, mountFn = shallowMount) => { + const createComponent = (glFeatures = {}, mountFn = shallowMount) => { wrapper = mountFn(TextEditor, { provide: { projectPath: mockProjectPath, projectNamespace: mockProjectNamespace, ciConfigPath: mockCiConfigPath, + defaultBranch: mockDefaultBranch, + glFeatures, }, attrs: { value: mockCiYml, @@ -54,7 +57,6 @@ describe('Pipeline Editor | Text editor component', () => { stubs: { EditorLite: MockEditorLite, }, - ...opts, }); }; @@ -66,7 +68,6 @@ describe('Pipeline Editor | Text editor component', () => { afterEach(() => { wrapper.destroy(); - wrapper = null; mockUse.mockClear(); mockRegisterCiSchema.mockClear(); @@ -100,25 +101,37 @@ describe('Pipeline Editor | Text editor component', () => { }); }); - describe('register CI schema', () => { - beforeEach(async () => { - createComponent(); - - // Since the editor will have already mounted, the event will have fired. - // To ensure we properly test this, we clear the mock and re-remit the event. - mockRegisterCiSchema.mockClear(); - mockUse.mockClear(); + describe('CI schema', () => { + describe('when `schema_linting` feature flag is on', () => { + beforeEach(() => { + createComponent({ schemaLinting: true }); + // Since the editor will have already mounted, the event will have fired. + // To ensure we properly test this, we clear the mock and re-remit the event. + mockRegisterCiSchema.mockClear(); + mockUse.mockClear(); + findEditor().vm.$emit(EDITOR_READY_EVENT); + }); - findEditor().vm.$emit(EDITOR_READY_EVENT); + it('configures editor with syntax highlight', () => { + expect(mockUse).toHaveBeenCalledTimes(1); + expect(mockRegisterCiSchema).toHaveBeenCalledTimes(1); + expect(mockRegisterCiSchema).toHaveBeenCalledWith({ + projectNamespace: mockProjectNamespace, + projectPath: mockProjectPath, + ref: mockCommitSha, + }); + }); }); - it('configures editor with syntax highlight', async () => { - expect(mockUse).toHaveBeenCalledTimes(1); - expect(mockRegisterCiSchema).toHaveBeenCalledTimes(1); - expect(mockRegisterCiSchema).toHaveBeenCalledWith({ - projectNamespace: mockProjectNamespace, - projectPath: mockProjectPath, - ref: mockCommitSha, + describe('when `schema_linting` feature flag is off', () => { + beforeEach(() => { + createComponent(); + findEditor().vm.$emit(EDITOR_READY_EVENT); + }); + + it('does not call the register CI schema function', () => { + expect(mockUse).not.toHaveBeenCalled(); + expect(mockRegisterCiSchema).not.toHaveBeenCalled(); }); }); }); |