diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-06 11:28:26 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-06 11:28:26 +0000 |
commit | 7d5e6412bef7fd457e22532faf859e551f8196fc (patch) | |
tree | dc62b4a7a5fad8ba0ba260ae82e95f8e984f2398 /spec | |
parent | 8e94dad32b10edebf79285c083176c2b7005ef64 (diff) | |
download | gitlab-ce-7d5e6412bef7fd457e22532faf859e551f8196fc.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/editor/editor_lite_spec.js | 49 | ||||
-rw-r--r-- | spec/lib/gitlab/import_export/all_models.yml | 1 |
2 files changed, 50 insertions, 0 deletions
diff --git a/spec/javascripts/editor/editor_lite_spec.js b/spec/javascripts/editor/editor_lite_spec.js index 154daccf82d..106264aa13f 100644 --- a/spec/javascripts/editor/editor_lite_spec.js +++ b/spec/javascripts/editor/editor_lite_spec.js @@ -1,5 +1,6 @@ import { editor as monacoEditor, Uri } from 'monaco-editor'; import Editor from '~/editor/editor_lite'; +import { DEFAULT_THEME, themes } from '~/ide/lib/themes'; describe('Base editor', () => { let editorEl; @@ -108,4 +109,52 @@ describe('Base editor', () => { expect(editor.model.getLanguageIdentifier().language).toEqual('plaintext'); }); }); + + describe('syntax highlighting theme', () => { + let themeDefineSpy; + let themeSetSpy; + let defaultScheme; + + beforeEach(() => { + themeDefineSpy = spyOn(monacoEditor, 'defineTheme'); + themeSetSpy = spyOn(monacoEditor, 'setTheme'); + defaultScheme = window.gon.user_color_scheme; + }); + + afterEach(() => { + window.gon.user_color_scheme = defaultScheme; + }); + + it('sets default syntax highlighting theme', () => { + const expectedTheme = themes.find(t => t.name === DEFAULT_THEME); + + editor = new Editor(); + + expect(themeDefineSpy).toHaveBeenCalledWith(DEFAULT_THEME, expectedTheme.data); + expect(themeSetSpy).toHaveBeenCalledWith(DEFAULT_THEME); + }); + + it('sets correct theme if it is set in users preferences', () => { + const expectedTheme = themes.find(t => t.name !== DEFAULT_THEME); + + expect(expectedTheme.name).not.toBe(DEFAULT_THEME); + + window.gon.user_color_scheme = expectedTheme.name; + editor = new Editor(); + + expect(themeDefineSpy).toHaveBeenCalledWith(expectedTheme.name, expectedTheme.data); + expect(themeSetSpy).toHaveBeenCalledWith(expectedTheme.name); + }); + + it('falls back to default theme if a selected one is not supported yet', () => { + const name = 'non-existent-theme'; + const nonExistentTheme = { name }; + + window.gon.user_color_scheme = nonExistentTheme.name; + editor = new Editor(); + + expect(themeDefineSpy).not.toHaveBeenCalled(); + expect(themeSetSpy).toHaveBeenCalledWith(DEFAULT_THEME); + }); + }); }); diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index bbb61b4c356..e579c8474b7 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -197,6 +197,7 @@ ci_pipelines: - source_bridge - source_job - sourced_pipelines +- source_project - triggered_by_pipeline - triggered_pipelines - child_pipelines |