blob: ed67a0948e47be2a40d347bf9de3f3b2b1d43486 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import { getBaseConfig } from '~/ide/lib/gitlab_web_ide/get_base_config';
import { TEST_HOST } from 'helpers/test_constants';
const TEST_GITLAB_WEB_IDE_PUBLIC_PATH = 'test/gitlab-web-ide/public/path';
const TEST_GITLAB_URL = 'https://gdk.test/';
const TEST_RELATIVE_URL_ROOT = '/gl_rel_root';
describe('~/ide/lib/gitlab_web_ide/get_base_config', () => {
beforeEach(() => {
// why: add trailing "/" to test that it gets removed
process.env.GITLAB_WEB_IDE_PUBLIC_PATH = `${TEST_GITLAB_WEB_IDE_PUBLIC_PATH}/`;
window.gon.gitlab_url = TEST_GITLAB_URL;
window.gon.relative_url_root = '';
});
it('with default, returns base properties for @gitlab/web-ide config', () => {
const actual = getBaseConfig();
expect(actual).toEqual({
baseUrl: `${TEST_HOST}/${TEST_GITLAB_WEB_IDE_PUBLIC_PATH}`,
gitlabUrl: TEST_GITLAB_URL,
});
});
it('with relative_url_root, returns baseUrl with relative url root', () => {
window.gon.relative_url_root = TEST_RELATIVE_URL_ROOT;
const actual = getBaseConfig();
expect(actual).toMatchObject({
baseUrl: `${TEST_HOST}${TEST_RELATIVE_URL_ROOT}/${TEST_GITLAB_WEB_IDE_PUBLIC_PATH}`,
});
});
});
|