debian-mirror-gitlab/spec/javascripts/repo/components/repo_editor_spec.js

61 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-09-10 17:25:29 +05:30
import Vue from 'vue';
2018-03-17 18:26:18 +05:30
import store from '~/ide/stores';
import repoEditor from '~/ide/components/repo_editor.vue';
import monacoLoader from '~/ide/monaco_loader';
import { file, resetStore } from '../helpers';
2017-09-10 17:25:29 +05:30
describe('RepoEditor', () => {
2018-03-17 18:26:18 +05:30
let vm;
beforeEach((done) => {
const f = file();
2017-09-10 17:25:29 +05:30
const RepoEditor = Vue.extend(repoEditor);
2018-03-17 18:26:18 +05:30
vm = new RepoEditor({
store,
});
f.active = true;
f.tempFile = true;
vm.$store.state.openFiles.push(f);
vm.$store.getters.activeFile.html = 'testing';
vm.monaco = true;
vm.$mount();
monacoLoader(['vs/editor/editor.main'], () => {
setTimeout(done, 0);
});
2017-09-10 17:25:29 +05:30
});
2018-03-17 18:26:18 +05:30
afterEach(() => {
vm.$destroy();
resetStore(vm.$store);
});
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
it('renders an ide container', (done) => {
2017-09-10 17:25:29 +05:30
Vue.nextTick(() => {
2018-03-17 18:26:18 +05:30
expect(vm.shouldHideEditor).toBeFalsy();
2017-09-10 17:25:29 +05:30
done();
});
});
2018-03-17 18:26:18 +05:30
describe('when open file is binary and not raw', () => {
beforeEach((done) => {
vm.$store.getters.activeFile.binary = true;
Vue.nextTick(done);
});
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
it('does not render the IDE', () => {
expect(vm.shouldHideEditor).toBeTruthy();
2017-09-10 17:25:29 +05:30
});
2018-03-17 18:26:18 +05:30
it('shows activeFile html', () => {
expect(vm.$el.textContent).toContain('testing');
2017-09-10 17:25:29 +05:30
});
});
});