Commit 5b2574d0 authored by Phil Hughes's avatar Phil Hughes

fixed failing specs

added more specs
parent c194d4ac
...@@ -18,6 +18,8 @@ export const discardAllChanges = ({ state, commit, dispatch }) => { ...@@ -18,6 +18,8 @@ export const discardAllChanges = ({ state, commit, dispatch }) => {
dispatch('closeFile', file); dispatch('closeFile', file);
} }
}); });
commit(types.REMOVE_ALL_CHANGES_FILES);
}; };
export const closeAllFiles = ({ state, dispatch }) => { export const closeAllFiles = ({ state, dispatch }) => {
......
...@@ -24,6 +24,7 @@ export const TOGGLE_TREE_OPEN = 'TOGGLE_TREE_OPEN'; ...@@ -24,6 +24,7 @@ export const TOGGLE_TREE_OPEN = 'TOGGLE_TREE_OPEN';
export const CREATE_TMP_TREE = 'CREATE_TMP_TREE'; export const CREATE_TMP_TREE = 'CREATE_TMP_TREE';
export const SET_LAST_COMMIT_URL = 'SET_LAST_COMMIT_URL'; export const SET_LAST_COMMIT_URL = 'SET_LAST_COMMIT_URL';
export const CREATE_TREE = 'CREATE_TREE'; export const CREATE_TREE = 'CREATE_TREE';
export const REMOVE_ALL_CHANGES_FILES = 'REMOVE_ALL_CHANGES_FILES';
// File mutation types // File mutation types
export const SET_FILE_DATA = 'SET_FILE_DATA'; export const SET_FILE_DATA = 'SET_FILE_DATA';
......
...@@ -33,4 +33,9 @@ export default { ...@@ -33,4 +33,9 @@ export default {
[types.CREATE_TMP_TREE](state, { parent, tmpEntry }) { [types.CREATE_TMP_TREE](state, { parent, tmpEntry }) {
parent.tree.push(tmpEntry); parent.tree.push(tmpEntry);
}, },
[types.REMOVE_ALL_CHANGES_FILES](state) {
Object.assign(state, {
changedFiles: [],
});
},
}; };
...@@ -36,8 +36,30 @@ describe('Multi-file store actions', () => { ...@@ -36,8 +36,30 @@ describe('Multi-file store actions', () => {
describe('discardAllChanges', () => { describe('discardAllChanges', () => {
beforeEach(() => { beforeEach(() => {
store.state.openFiles.push(file('discardAll')); const f = file('discardAll');
store.state.openFiles[0].changed = true; f.changed = true;
store.state.openFiles.push(f);
store.state.changedFiles.push(f);
});
it('discards changes in file', (done) => {
store.dispatch('discardAllChanges')
.then(() => {
expect(store.state.openFiles.changed).toBeFalsy();
})
.then(done)
.catch(done.fail);
});
it('removes all files from changedFiles state', (done) => {
store.dispatch('discardAllChanges')
.then(() => {
expect(store.state.changedFiles.length).toBe(0);
expect(store.state.openFiles.length).toBe(1);
})
.then(done)
.catch(done.fail);
}); });
}); });
......
...@@ -68,4 +68,14 @@ describe('Multi-file store tree mutations', () => { ...@@ -68,4 +68,14 @@ describe('Multi-file store tree mutations', () => {
expect(localTree.tree[0].name).toBe(tmpEntry.name); expect(localTree.tree[0].name).toBe(tmpEntry.name);
}); });
}); });
describe('REMOVE_ALL_CHANGES_FILES', () => {
it('removes all files from changedFiles state', () => {
localState.changedFiles.push(file('REMOVE_ALL_CHANGES_FILES'));
mutations.REMOVE_ALL_CHANGES_FILES(localState);
expect(localState.changedFiles.length).toBe(0);
});
});
}); });
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