diff options
author | Phil Hughes <me@iamphill.com> | 2017-10-30 17:36:24 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-10-30 17:36:24 +0300 |
commit | 5c75d750cf3b86e7e61df89b4b0efef1207829e0 (patch) | |
tree | 82b7ebe0e9dc821ba6e9ffb869ed87818be6fb04 /spec/javascripts/repo/components | |
parent | 4b80cde2c803ead14ca34fc71991b4a7b458ab00 (diff) |
addressed feedback from review
spec fixes
Diffstat (limited to 'spec/javascripts/repo/components')
4 files changed, 24 insertions, 16 deletions
diff --git a/spec/javascripts/repo/components/repo_edit_button_spec.js b/spec/javascripts/repo/components/repo_edit_button_spec.js index aee2dd6ad55..44018464b35 100644 --- a/spec/javascripts/repo/components/repo_edit_button_spec.js +++ b/spec/javascripts/repo/components/repo_edit_button_spec.js @@ -15,7 +15,6 @@ describe('RepoEditButton', () => { }); f.active = true; - f.changed = true; vm.$store.dispatch('setInitialData', { canCommit: true, onTopOfBranch: true, @@ -45,17 +44,23 @@ describe('RepoEditButton', () => { expect(vm.$el.querySelector('.btn').textContent.trim()).toBe('Cancel edit'); }); - it('toggles edit mode on click', () => { + it('toggles edit mode on click', (done) => { vm.$mount(); vm.$el.querySelector('.btn').click(); - expect(vm.$el.querySelector('.btn').textContent.trim()).toBe('Cancel edit'); + vm.$nextTick(() => { + expect(vm.$el.querySelector('.btn').textContent.trim()).toBe('Cancel edit'); + + done(); + }); }); describe('discardPopupOpen', () => { beforeEach(() => { vm.$store.state.discardPopupOpen = true; + vm.$store.state.editMode = true; + vm.$store.state.openFiles[0].changed = true; vm.$mount(); }); diff --git a/spec/javascripts/repo/components/repo_file_spec.js b/spec/javascripts/repo/components/repo_file_spec.js index 18ae461128e..c45f8a18d1f 100644 --- a/spec/javascripts/repo/components/repo_file_spec.js +++ b/spec/javascripts/repo/components/repo_file_spec.js @@ -5,6 +5,7 @@ import { file, resetStore } from '../helpers'; describe('RepoFile', () => { const updated = 'updated'; + let vm; function createComponent(propsData) { const RepoFile = Vue.extend(repoFile); @@ -21,7 +22,7 @@ describe('RepoFile', () => { it('renders link, icon, name and last commit details', () => { const RepoFile = Vue.extend(repoFile); - const vm = new RepoFile({ + vm = new RepoFile({ store, propsData: { file: file(), @@ -43,7 +44,7 @@ describe('RepoFile', () => { }); it('does render if hasFiles is true and is loading tree', () => { - const vm = createComponent({ + vm = createComponent({ file: file(), }); @@ -53,7 +54,7 @@ describe('RepoFile', () => { it('renders a spinner if the file is loading', () => { const f = file(); f.loading = true; - const vm = createComponent({ + vm = createComponent({ file: f, }); @@ -62,7 +63,7 @@ describe('RepoFile', () => { }); it('does not render commit message and datetime if mini', (done) => { - const vm = createComponent({ + vm = createComponent({ file: file(), }); vm.$store.state.openFiles.push(vm.file); @@ -76,7 +77,7 @@ describe('RepoFile', () => { }); it('fires clickedTreeRow when the link is clicked', () => { - const vm = createComponent({ + vm = createComponent({ file: file(), }); @@ -89,7 +90,6 @@ describe('RepoFile', () => { describe('submodule', () => { let f; - let vm; beforeEach(() => { f = file('submodule name', '123456789'); diff --git a/spec/javascripts/repo/components/repo_tab_spec.js b/spec/javascripts/repo/components/repo_tab_spec.js index 0d1c22a2f89..df0ca55aafc 100644 --- a/spec/javascripts/repo/components/repo_tab_spec.js +++ b/spec/javascripts/repo/components/repo_tab_spec.js @@ -4,6 +4,8 @@ import repoTab from '~/repo/components/repo_tab.vue'; import { file, resetStore } from '../helpers'; describe('RepoTab', () => { + let vm; + function createComponent(propsData) { const RepoTab = Vue.extend(repoTab); @@ -18,7 +20,7 @@ describe('RepoTab', () => { }); it('renders a close link and a name link', () => { - const vm = createComponent({ + vm = createComponent({ tab: file(), }); vm.$store.state.openFiles.push(vm.tab); @@ -30,7 +32,7 @@ describe('RepoTab', () => { }); it('calls setFileActive when clicking tab', () => { - const vm = createComponent({ + vm = createComponent({ tab: file(), }); @@ -42,7 +44,7 @@ describe('RepoTab', () => { }); it('calls closeFile when clicking close button', () => { - const vm = createComponent({ + vm = createComponent({ tab: file(), }); @@ -56,7 +58,7 @@ describe('RepoTab', () => { it('renders an fa-circle icon if tab is changed', () => { const tab = file(); tab.changed = true; - const vm = createComponent({ + vm = createComponent({ tab, }); @@ -69,7 +71,7 @@ describe('RepoTab', () => { const tab = file(); tab.changed = true; tab.opened = true; - const vm = createComponent({ + vm = createComponent({ tab, }); vm.$store.state.openFiles.push(tab); @@ -87,7 +89,7 @@ describe('RepoTab', () => { it('closes tab when clicking close btn', (done) => { const tab = file('lose'); tab.opened = true; - const vm = createComponent({ + vm = createComponent({ tab, }); vm.$store.state.openFiles.push(tab); diff --git a/spec/javascripts/repo/components/repo_tabs_spec.js b/spec/javascripts/repo/components/repo_tabs_spec.js index 73ecdab6967..d0246cc72e6 100644 --- a/spec/javascripts/repo/components/repo_tabs_spec.js +++ b/spec/javascripts/repo/components/repo_tabs_spec.js @@ -5,6 +5,7 @@ import { file, resetStore } from '../helpers'; describe('RepoTabs', () => { const openedFiles = [file(), file()]; + let vm; function createComponent() { const RepoTabs = Vue.extend(repoTabs); @@ -19,7 +20,7 @@ describe('RepoTabs', () => { }); it('renders a list of tabs', (done) => { - const vm = createComponent(); + vm = createComponent(); openedFiles[0].active = true; vm.$store.state.openFiles = openedFiles; |