Commit 44fceac5 authored by Jay Swain's avatar Jay Swain

Feedback: use mutation_types

parent 9214463a
...@@ -10,7 +10,7 @@ export default { ...@@ -10,7 +10,7 @@ export default {
...mapState(['open']), ...mapState(['open']),
}, },
methods: { methods: {
...mapActions(['closeDrawer', 'openDrawer']), ...mapActions(['closeDrawer']),
}, },
}; };
</script> </script>
......
import * as types from './mutation_types';
export default { export default {
closeDrawer({ commit }) { closeDrawer({ commit }) {
commit('closeDrawer'); commit(types.CLOSE_DRAWER);
}, },
openDrawer({ commit }) { openDrawer({ commit }) {
commit('openDrawer'); commit(types.OPEN_DRAWER);
}, },
}; };
export const CLOSE_DRAWER = 'CLOSE_DRAWER';
export const OPEN_DRAWER = 'OPEN_DRAWER';
import * as types from './mutation_types';
export default { export default {
closeDrawer(state) { [types.CLOSE_DRAWER](state) {
state.open = false; state.open = false;
}, },
openDrawer(state) { [types.OPEN_DRAWER](state) {
state.open = true; state.open = true;
}, },
}; };
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import actions from '~/whats_new/store/actions'; import actions from '~/whats_new/store/actions';
import * as types from '~/whats_new/store/mutation_types';
describe('whats new actions', () => { describe('whats new actions', () => {
describe('openDrawer', () => { describe('openDrawer', () => {
it('should commit openDrawer', () => { it('should commit openDrawer', () => {
testAction(actions.openDrawer, {}, {}, [{ type: 'openDrawer' }]); testAction(actions.openDrawer, {}, {}, [{ type: types.OPEN_DRAWER }]);
}); });
}); });
describe('closeDrawer', () => { describe('closeDrawer', () => {
it('should commit closeDrawer', () => { it('should commit closeDrawer', () => {
testAction(actions.closeDrawer, {}, {}, [{ type: 'closeDrawer' }]); testAction(actions.closeDrawer, {}, {}, [{ type: types.CLOSE_DRAWER }]);
}); });
}); });
}); });
import mutations from '~/whats_new/store/mutations'; import mutations from '~/whats_new/store/mutations';
import createState from '~/whats_new/store/state'; import createState from '~/whats_new/store/state';
import * as types from '~/whats_new/store/mutation_types';
describe('whats new mutations', () => { describe('whats new mutations', () => {
let state; let state;
...@@ -10,14 +11,14 @@ describe('whats new mutations', () => { ...@@ -10,14 +11,14 @@ describe('whats new mutations', () => {
describe('openDrawer', () => { describe('openDrawer', () => {
it('sets open to true', () => { it('sets open to true', () => {
mutations.openDrawer(state); mutations[types.OPEN_DRAWER](state);
expect(state.open).toBe(true); expect(state.open).toBe(true);
}); });
}); });
describe('closeDrawer', () => { describe('closeDrawer', () => {
it('sets open to false', () => { it('sets open to false', () => {
mutations.closeDrawer(state); mutations[types.CLOSE_DRAWER](state);
expect(state.open).toBe(false); expect(state.open).toBe(false);
}); });
}); });
......
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