From feae8975527fa3742b6cf279d19c27f724bf0a8e Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 4 Sep 2018 11:08:20 +0100 Subject: karma fixes --- app/assets/javascripts/ide/stores/actions.js | 8 ++++---- spec/javascripts/ide/stores/actions_spec.js | 26 ++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/ide/stores/actions.js b/app/assets/javascripts/ide/stores/actions.js index 734ee1995ee..b8b64aead30 100644 --- a/app/assets/javascripts/ide/stores/actions.js +++ b/app/assets/javascripts/ide/stores/actions.js @@ -124,25 +124,25 @@ export const scrollToTab = () => { }; export const stageAllChanges = ({ state, commit, dispatch }) => { - const activeFile = state.openFiles[0]; + const openFile = state.openFiles[0]; commit(types.SET_LAST_COMMIT_MSG, ''); state.changedFiles.forEach(file => commit(types.STAGE_CHANGE, file.path)); dispatch('openPendingTab', { - file: state.stagedFiles.find(f => f.path === activeFile.path), + file: state.stagedFiles.find(f => f.path === openFile.path), keyPrefix: stageKeys.staged, }); }; export const unstageAllChanges = ({ state, commit, dispatch }) => { - const activeFile = state.openFiles[0]; + const openFile = state.openFiles[0]; state.stagedFiles.forEach(file => commit(types.UNSTAGE_CHANGE, file.path)); dispatch('openPendingTab', { - file: state.changedFiles.find(f => f.path === activeFile.path), + file: state.changedFiles.find(f => f.path === openFile.path), keyPrefix: stageKeys.unstaged, }); }; diff --git a/spec/javascripts/ide/stores/actions_spec.js b/spec/javascripts/ide/stores/actions_spec.js index d84f1717a61..c9a1158a14e 100644 --- a/spec/javascripts/ide/stores/actions_spec.js +++ b/spec/javascripts/ide/stores/actions_spec.js @@ -305,7 +305,11 @@ describe('Multi-file store actions', () => { describe('stageAllChanges', () => { it('adds all files from changedFiles to stagedFiles', done => { - store.state.changedFiles.push(file(), file('new')); + const openFile = { ...file(), path: 'test' }; + + store.state.openFiles.push(openFile); + store.state.stagedFiles.push(openFile); + store.state.changedFiles.push(openFile, file('new')); testAction( stageAllChanges, @@ -316,7 +320,12 @@ describe('Multi-file store actions', () => { { type: types.STAGE_CHANGE, payload: store.state.changedFiles[0].path }, { type: types.STAGE_CHANGE, payload: store.state.changedFiles[1].path }, ], - [], + [ + { + type: 'openPendingTab', + payload: { file: openFile, keyPrefix: 'staged' }, + }, + ], done, ); }); @@ -324,7 +333,11 @@ describe('Multi-file store actions', () => { describe('unstageAllChanges', () => { it('removes all files from stagedFiles after unstaging', done => { - store.state.stagedFiles.push(file(), file('new')); + const openFile = { ...file(), path: 'test' }; + + store.state.openFiles.push(openFile); + store.state.changedFiles.push(openFile); + store.state.stagedFiles.push(openFile, file('new')); testAction( unstageAllChanges, @@ -334,7 +347,12 @@ describe('Multi-file store actions', () => { { type: types.UNSTAGE_CHANGE, payload: store.state.stagedFiles[0].path }, { type: types.UNSTAGE_CHANGE, payload: store.state.stagedFiles[1].path }, ], - [], + [ + { + type: 'openPendingTab', + payload: { file: openFile, keyPrefix: 'unstaged' }, + }, + ], done, ); }); -- cgit v1.2.1