From 0fdcb703d1756f12df0bebc8ca6ccfda8659725e Mon Sep 17 00:00:00 2001
From: Luke "Jared" Bennett <lbennett@gitlab.com>
Date: Wed, 26 Jul 2017 17:52:50 +0100
Subject: [PATCH] Fix repo_editor_spec because of async loader changes

---
 app/assets/javascripts/repo/index.js       |  4 ++--
 app/assets/javascripts/repo/repo_editor.js |  7 +++++--
 spec/javascripts/repo/repo_editor_spec.js  | 10 ++++++++++
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/app/assets/javascripts/repo/index.js b/app/assets/javascripts/repo/index.js
index 8429709..99eb782 100644
--- a/app/assets/javascripts/repo/index.js
+++ b/app/assets/javascripts/repo/index.js
@@ -9,7 +9,7 @@ import RepoCommitSection from './repo_commit_section.vue';
 import RepoTabs from './repo_tabs.vue';
 import RepoFileButtons from './repo_file_buttons.vue';
 import RepoBinaryViewer from './repo_binary_viewer.vue';
-import RepoEditor from './repo_editor';
+import { repoEditorLoader } from './repo_editor';
 import RepoMiniMixin from './repo_mini_mixin';
 
 function initRepo() {
@@ -44,7 +44,7 @@ function initRepo() {
       'repo-tabs': RepoTabs,
       'repo-file-buttons': RepoFileButtons,
       'repo-binary-viewer': RepoBinaryViewer,
-      'repo-editor': RepoEditor,
+      'repo-editor': repoEditorLoader,
       'repo-commit-section': RepoCommitSection,
     },
   });
diff --git a/app/assets/javascripts/repo/repo_editor.js b/app/assets/javascripts/repo/repo_editor.js
index 0b9dc38..0dee33b 100644
--- a/app/assets/javascripts/repo/repo_editor.js
+++ b/app/assets/javascripts/repo/repo_editor.js
@@ -106,7 +106,7 @@ const RepoEditor = {
   },
 };
 
-function asyncLoadRepoEditor() {
+function repoEditorLoader() {
   return new Promise((resolve) => {
     monacoLoader(['vs/editor/editor.main'], () => {
       Store.monaco = monaco;
@@ -116,4 +116,7 @@ function asyncLoadRepoEditor() {
   });
 }
 
-export default asyncLoadRepoEditor;
+export {
+  RepoEditor as default,
+  repoEditorLoader,
+};
diff --git a/spec/javascripts/repo/repo_editor_spec.js b/spec/javascripts/repo/repo_editor_spec.js
index 9e02cd9..699c248 100644
--- a/spec/javascripts/repo/repo_editor_spec.js
+++ b/spec/javascripts/repo/repo_editor_spec.js
@@ -1,5 +1,6 @@
 import Vue from 'vue';
 import repoEditor from '~/repo/repo_editor';
+import RepoStore from '~/repo/repo_store';
 
 describe('RepoEditor', () => {
   function createComponent() {
@@ -9,6 +10,15 @@ describe('RepoEditor', () => {
   }
 
   it('renders an ide container', () => {
+    const monacoInstance = jasmine.createSpyObj('monacoInstance', ['onMouseUp', 'onKeyUp', 'setModel']);
+    const monaco = {
+      editor: jasmine.createSpyObj('editor', ['create']),
+    };
+    RepoStore.monaco = monaco;
+
+    monaco.editor.create.and.returnValue(monacoInstance);
+    spyOn(repoEditor.watch, 'blobRaw');
+
     const vm = createComponent();
 
     expect(vm.$el.id).toEqual('ide');
--
libgit2 0.27.1