Commit d22bb039 authored by Phil Hughes's avatar Phil Hughes

fixed failing specs

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