Commit feae8975 authored by Phil Hughes's avatar Phil Hughes

karma fixes

parent 9badf9e7
...@@ -124,25 +124,25 @@ export const scrollToTab = () => { ...@@ -124,25 +124,25 @@ export const scrollToTab = () => {
}; };
export const stageAllChanges = ({ state, commit, dispatch }) => { export const stageAllChanges = ({ state, commit, dispatch }) => {
const activeFile = state.openFiles[0]; const openFile = state.openFiles[0];
commit(types.SET_LAST_COMMIT_MSG, ''); commit(types.SET_LAST_COMMIT_MSG, '');
state.changedFiles.forEach(file => commit(types.STAGE_CHANGE, file.path)); state.changedFiles.forEach(file => commit(types.STAGE_CHANGE, file.path));
dispatch('openPendingTab', { dispatch('openPendingTab', {
file: state.stagedFiles.find(f => f.path === activeFile.path), file: state.stagedFiles.find(f => f.path === openFile.path),
keyPrefix: stageKeys.staged, keyPrefix: stageKeys.staged,
}); });
}; };
export const unstageAllChanges = ({ state, commit, dispatch }) => { 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)); state.stagedFiles.forEach(file => commit(types.UNSTAGE_CHANGE, file.path));
dispatch('openPendingTab', { dispatch('openPendingTab', {
file: state.changedFiles.find(f => f.path === activeFile.path), file: state.changedFiles.find(f => f.path === openFile.path),
keyPrefix: stageKeys.unstaged, keyPrefix: stageKeys.unstaged,
}); });
}; };
......
...@@ -305,7 +305,11 @@ describe('Multi-file store actions', () => { ...@@ -305,7 +305,11 @@ describe('Multi-file store actions', () => {
describe('stageAllChanges', () => { describe('stageAllChanges', () => {
it('adds all files from changedFiles to stagedFiles', done => { 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( testAction(
stageAllChanges, stageAllChanges,
...@@ -316,7 +320,12 @@ describe('Multi-file store actions', () => { ...@@ -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[0].path },
{ type: types.STAGE_CHANGE, payload: store.state.changedFiles[1].path }, { type: types.STAGE_CHANGE, payload: store.state.changedFiles[1].path },
], ],
[], [
{
type: 'openPendingTab',
payload: { file: openFile, keyPrefix: 'staged' },
},
],
done, done,
); );
}); });
...@@ -324,7 +333,11 @@ describe('Multi-file store actions', () => { ...@@ -324,7 +333,11 @@ describe('Multi-file store actions', () => {
describe('unstageAllChanges', () => { describe('unstageAllChanges', () => {
it('removes all files from stagedFiles after unstaging', done => { 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( testAction(
unstageAllChanges, unstageAllChanges,
...@@ -334,7 +347,12 @@ describe('Multi-file store actions', () => { ...@@ -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[0].path },
{ type: types.UNSTAGE_CHANGE, payload: store.state.stagedFiles[1].path }, { type: types.UNSTAGE_CHANGE, payload: store.state.stagedFiles[1].path },
], ],
[], [
{
type: 'openPendingTab',
payload: { file: openFile, keyPrefix: 'unstaged' },
},
],
done, done,
); );
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment