2020-11-25 01:09:20 -05:00
|
|
|
import { TEST_HOST } from 'helpers/test_constants';
|
|
|
|
import extendStore from '~/ide/stores/extend';
|
|
|
|
import { initIde } from '~/ide';
|
2021-01-13 22:10:47 -05:00
|
|
|
import Editor from '~/ide/lib/editor';
|
2021-02-01 10:08:56 -05:00
|
|
|
import { IDE_DATASET } from './mock_data';
|
2020-11-25 01:09:20 -05:00
|
|
|
|
|
|
|
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);
|
2021-01-13 22:10:47 -05:00
|
|
|
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;
|
2020-11-25 01:09:20 -05:00
|
|
|
};
|