diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/frontend/ide/stores/getters_spec.js | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/frontend/ide/stores/getters_spec.js')
-rw-r--r-- | spec/frontend/ide/stores/getters_spec.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/frontend/ide/stores/getters_spec.js b/spec/frontend/ide/stores/getters_spec.js index dcf05329ce0..e24f08fa802 100644 --- a/spec/frontend/ide/stores/getters_spec.js +++ b/spec/frontend/ide/stores/getters_spec.js @@ -1,3 +1,4 @@ +import { TEST_HOST } from 'helpers/test_constants'; import * as getters from '~/ide/stores/getters'; import { createStore } from '~/ide/stores'; import { file } from '../helpers'; @@ -482,4 +483,48 @@ describe('IDE store getters', () => { expect(localStore.getters.getAvailableFileName('foo-bar1.jpg')).toBe('foo-bar1.jpg'); }); }); + + describe('getUrlForPath', () => { + it('returns a route url for the given path', () => { + localState.currentProjectId = 'test/test'; + localState.currentBranchId = 'master'; + + expect(localStore.getters.getUrlForPath('path/to/foo/bar-1.jpg')).toBe( + `/project/test/test/tree/master/-/path/to/foo/bar-1.jpg/`, + ); + }); + }); + + describe('getJsonSchemaForPath', () => { + beforeEach(() => { + localState.currentProjectId = 'path/to/some/project'; + localState.currentBranchId = 'master'; + }); + + it('returns a json schema uri and match config for a json/yaml file that can be loaded by monaco', () => { + expect(localStore.getters.getJsonSchemaForPath('.gitlab-ci.yml')).toEqual({ + fileMatch: ['*.gitlab-ci.yml'], + uri: `${TEST_HOST}/path/to/some/project/-/schema/master/.gitlab-ci.yml`, + }); + }); + + it('returns a path containing sha if branch details are present in state', () => { + localState.projects['path/to/some/project'] = { + name: 'project', + branches: { + master: { + name: 'master', + commit: { + id: 'abcdef123456', + }, + }, + }, + }; + + expect(localStore.getters.getJsonSchemaForPath('.gitlab-ci.yml')).toEqual({ + fileMatch: ['*.gitlab-ci.yml'], + uri: `${TEST_HOST}/path/to/some/project/-/schema/abcdef123456/.gitlab-ci.yml`, + }); + }); + }); }); |