diff options
author | Marcia Ramos <virtua.creative@gmail.com> | 2017-08-17 22:03:27 +0300 |
---|---|---|
committer | Marcia Ramos <virtua.creative@gmail.com> | 2017-08-17 22:03:27 +0300 |
commit | b8485707f268e95b28ef051cc5a4250df22cd13b (patch) | |
tree | 882a11d3ac70c1eb3762ce8ee55866fdef438640 /spec/javascripts/repo/components/repo_editor_spec.js | |
parent | ab6bf68c4ed62a487fa7e6390462c32bf836c8d6 (diff) | |
parent | f0ac0daf6a8788f57b98eaf29b0056899027ae68 (diff) |
Fix conflict
Merge branch 'master' into 'docs-article-undo-things-in-git'
# Conflicts:
# doc/articles/index.md
Diffstat (limited to 'spec/javascripts/repo/components/repo_editor_spec.js')
-rw-r--r-- | spec/javascripts/repo/components/repo_editor_spec.js | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/spec/javascripts/repo/components/repo_editor_spec.js b/spec/javascripts/repo/components/repo_editor_spec.js index 35e0c995163..85d55d171f9 100644 --- a/spec/javascripts/repo/components/repo_editor_spec.js +++ b/spec/javascripts/repo/components/repo_editor_spec.js @@ -1,26 +1,49 @@ 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(); - } + this.vm = new RepoEditor().$mount(); + }); + + it('renders an ide container', (done) => { + this.vm.openedFiles = ['idiidid']; + this.vm.binary = false; - it('renders an ide container', () => { - const monacoInstance = jasmine.createSpyObj('monacoInstance', ['onMouseUp', 'onKeyUp', 'setModel', 'updateOptions']); - const monaco = { - editor: jasmine.createSpyObj('editor', ['create']), - }; - RepoStore.monaco = monaco; + Vue.nextTick(() => { + expect(this.vm.shouldHideEditor).toBe(false); + expect(this.vm.$el.id).toEqual('ide'); + expect(this.vm.$el.tagName).toBe('DIV'); + done(); + }); + }); - monaco.editor.create.and.returnValue(monacoInstance); - spyOn(repoEditor.watch, 'blobRaw'); + describe('when there are no open files', () => { + it('does not render the ide', (done) => { + this.vm.openedFiles = []; + + Vue.nextTick(() => { + expect(this.vm.shouldHideEditor).toBe(true); + expect(this.vm.$el.tagName).not.toBeDefined(); + done(); + }); + }); + }); - const vm = createComponent(); + describe('when open file is binary and not raw', () => { + it('does not render the IDE', (done) => { + this.vm.binary = true; + this.vm.activeFile = { + raw: false, + }; - expect(vm.$el.id).toEqual('ide'); + Vue.nextTick(() => { + expect(this.vm.shouldHideEditor).toBe(true); + expect(this.vm.$el.tagName).not.toBeDefined(); + done(); + }); + }); }); }); |