diff options
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(); + }); + }); }); }); |