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

Feedback: use mutation_types

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