Commit d22bb039 authored by Phil Hughes's avatar Phil Hughes

fixed failing specs

parent 5fceb8d1
...@@ -6,11 +6,11 @@ import monacoLoader from '../monaco_loader'; ...@@ -6,11 +6,11 @@ import monacoLoader from '../monaco_loader';
import Editor from '../lib/editor'; import Editor from '../lib/editor';
export default { export default {
destroyed() { beforeDestroy() {
this.editor.dispose(); this.editor.dispose();
}, },
mounted() { mounted() {
if (this.monaco) { if (this.editor && monaco) {
this.initMonaco(); this.initMonaco();
} else { } else {
monacoLoader(['vs/editor/editor.main'], () => { monacoLoader(['vs/editor/editor.main'], () => {
...@@ -32,7 +32,7 @@ export default { ...@@ -32,7 +32,7 @@ export default {
this.getRawFileData(this.activeFile) this.getRawFileData(this.activeFile)
.then(() => { .then(() => {
this.editor.createInstance(this.$el); this.editor.createInstance(this.$refs.editor);
}) })
.then(() => this.setupEditor()) .then(() => this.setupEditor())
.catch(() => flash('Error setting up monaco. Please try again.')); .catch(() => flash('Error setting up monaco. Please try again.'));
...@@ -76,9 +76,14 @@ export default { ...@@ -76,9 +76,14 @@ export default {
class="blob-viewer-container blob-editor-container" class="blob-viewer-container blob-editor-container"
> >
<div <div
v-if="shouldHideEditor" v-show="shouldHideEditor"
v-html="activeFile.html" v-html="activeFile.html"
> >
</div> </div>
<div
v-show="!shouldHideEditor"
ref="editor"
>
</div>
</div> </div>
</template> </template>
import Vue from 'vue'; import Vue from 'vue';
import store from '~/repo/stores'; import store from '~/repo/stores';
import repoEditor from '~/repo/components/repo_editor.vue'; import repoEditor from '~/repo/components/repo_editor.vue';
import monacoLoader from '~/repo/monaco_loader';
import { file, resetStore } from '../helpers'; import { file, resetStore } from '../helpers';
describe('RepoEditor', () => { describe('RepoEditor', () => {
let vm; let vm;
beforeEach(() => { beforeEach((done) => {
const f = file(); const f = file();
const RepoEditor = Vue.extend(repoEditor); const RepoEditor = Vue.extend(repoEditor);
...@@ -21,6 +22,10 @@ describe('RepoEditor', () => { ...@@ -21,6 +22,10 @@ describe('RepoEditor', () => {
vm.monaco = true; vm.monaco = true;
vm.$mount(); vm.$mount();
monacoLoader(['vs/editor/editor.main'], () => {
setTimeout(done, 0);
});
}); });
afterEach(() => { afterEach(() => {
...@@ -32,7 +37,6 @@ describe('RepoEditor', () => { ...@@ -32,7 +37,6 @@ describe('RepoEditor', () => {
it('renders an ide container', (done) => { it('renders an ide container', (done) => {
Vue.nextTick(() => { Vue.nextTick(() => {
expect(vm.shouldHideEditor).toBeFalsy(); expect(vm.shouldHideEditor).toBeFalsy();
expect(vm.$el.textContent.trim()).toBe('');
done(); done();
}); });
...@@ -50,7 +54,7 @@ describe('RepoEditor', () => { ...@@ -50,7 +54,7 @@ describe('RepoEditor', () => {
}); });
it('shows activeFile html', () => { it('shows activeFile html', () => {
expect(vm.$el.textContent.trim()).toBe('testing'); expect(vm.$el.textContent).toContain('testing');
}); });
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment