summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryce Johnson <bryce@gitlab.com>2017-08-15 11:10:24 -0400
committerBryce Johnson <bryce@gitlab.com>2017-08-15 11:10:24 -0400
commitc415e90192d08733d6b625d44da1f82e1aaafd6a (patch)
treec9beba03f56f00dd752595c5d42273bd3f192a78
parent8f8fd1582dced4fae5aa8ca7c97f63037fe3ab92 (diff)
downloadgitlab-ce-bpj-repo-editor-fixes.tar.gz
Clean up repo editor specs.bpj-repo-editor-fixes
-rw-r--r--spec/javascripts/repo/components/repo_editor_spec.js46
1 files changed, 19 insertions, 27 deletions
diff --git a/spec/javascripts/repo/components/repo_editor_spec.js b/spec/javascripts/repo/components/repo_editor_spec.js
index a709633d2e8..85d55d171f9 100644
--- a/spec/javascripts/repo/components/repo_editor_spec.js
+++ b/spec/javascripts/repo/components/repo_editor_spec.js
@@ -1,38 +1,32 @@
import Vue from 'vue';
import repoEditor from '~/repo/components/repo_editor.vue';
-import RepoStore from '~/repo/stores/repo_store';
describe('RepoEditor', () => {
- function createComponent() {
+ beforeEach(() => {
const RepoEditor = Vue.extend(repoEditor);
- return new RepoEditor().$mount();
- }
-
- it('renders an ide container', () => {
- const monacoInstance = jasmine.createSpyObj('monacoInstance', ['onMouseUp', 'onKeyUp', 'setModel', 'updateOptions']);
- const monaco = {
- editor: jasmine.createSpyObj('editor', ['create']),
- };
- RepoStore.monaco = monaco;
-
- monaco.editor.create.and.returnValue(monacoInstance);
- spyOn(repoEditor.watch, 'blobRaw');
+ this.vm = new RepoEditor().$mount();
+ });
- const vm = createComponent();
+ it('renders an ide container', (done) => {
+ this.vm.openedFiles = ['idiidid'];
+ this.vm.binary = false;
- expect(vm.$el.id).toEqual('ide');
+ Vue.nextTick(() => {
+ expect(this.vm.shouldHideEditor).toBe(false);
+ expect(this.vm.$el.id).toEqual('ide');
+ expect(this.vm.$el.tagName).toBe('DIV');
+ done();
+ });
});
describe('when there are no open files', () => {
it('does not render the ide', (done) => {
- const vm = createComponent();
-
- vm.openedFiles = [];
+ this.vm.openedFiles = [];
Vue.nextTick(() => {
- expect(vm.shouldHideEditor).toBe(true);
- expect(vm.$el.style.display).toBe('none');
+ expect(this.vm.shouldHideEditor).toBe(true);
+ expect(this.vm.$el.tagName).not.toBeDefined();
done();
});
});
@@ -40,16 +34,14 @@ describe('RepoEditor', () => {
describe('when open file is binary and not raw', () => {
it('does not render the IDE', (done) => {
- const vm = createComponent();
-
- vm.binary = true;
- vm.activeFile = {
+ this.vm.binary = true;
+ this.vm.activeFile = {
raw: false,
};
Vue.nextTick(() => {
- expect(vm.shouldHideEditor).toBe(true);
- expect(vm.$el.style.display).toBe('none');
+ expect(this.vm.shouldHideEditor).toBe(true);
+ expect(this.vm.$el.tagName).not.toBeDefined();
done();
});
});