Welcome to mirror list, hosted at ThFree Co, Russian Federation.

start.js « helpers « ide « frontend_integration « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 43a996286e703c4a9340c253d88d4d4332734199 (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
import { TEST_HOST } from 'helpers/test_constants';
import extendStore from '~/ide/stores/extend';
import { IDE_DATASET } from './mock_data';
import { initIde } from '~/ide';
import Editor from '~/ide/lib/editor';

export default (container, { isRepoEmpty = false, path = '' } = {}) => {
  global.jsdom.reconfigure({
    url: `${TEST_HOST}/-/ide/project/gitlab-test/lorem-ipsum${
      isRepoEmpty ? '-empty' : ''
    }/tree/master/-/${path}`,
  });

  const el = document.createElement('div');
  Object.assign(el.dataset, IDE_DATASET);
  container.appendChild(el);
  const vm = initIde(el, { extendStore });

  // We need to dispose of editor Singleton things or tests will bump into eachother
  vm.$on('destroy', () => {
    if (Editor.editorInstance) {
      Editor.editorInstance.modelManager.dispose();
      Editor.editorInstance.dispose();
      Editor.editorInstance = null;
    }
  });

  return vm;
};