Commit 49441ba4 authored by Paul Slaughter's avatar Paul Slaughter

Create IDE router module

- This is to help decouple the store from the router instance
- Instead of making direct calls, we'll update state and the
  router will react to the state change
parent 98a0373d
import * as types from './mutation_types';
// eslint-disable-next-line import/prefer-default-export
export const push = ({ commit }, fullPath) => {
commit(types.PUSH, fullPath);
};
import state from './state';
import mutations from './mutations';
import * as actions from './actions';
export default {
namespaced: true,
state,
mutations,
actions,
};
// eslint-disable-next-line import/prefer-default-export
export const PUSH = 'PUSH';
import * as types from './mutation_types';
export default {
[types.PUSH](state, fullPath) {
state.fullPath = fullPath;
},
};
export default () => ({
fullPath: '',
});
import * as actions from '~/ide/stores/modules/router/actions';
import * as types from '~/ide/stores/modules/router/mutation_types';
import testAction from 'helpers/vuex_action_helper';
const TEST_PATH = 'test/path/abc';
describe('ide/stores/modules/router/actions', () => {
describe('push', () => {
it('commits mutation', () => {
return testAction(
actions.push,
TEST_PATH,
{},
[{ type: types.PUSH, payload: TEST_PATH }],
[],
);
});
});
});
import mutations from '~/ide/stores/modules/router/mutations';
import * as types from '~/ide/stores/modules/router/mutation_types';
import createState from '~/ide/stores/modules/router/state';
const TEST_PATH = 'test/path/abc';
describe('ide/stores/modules/router/mutations', () => {
let state;
beforeEach(() => {
state = createState();
});
describe(types.PUSH, () => {
it('updates state', () => {
expect(state.fullPath).toBe('');
mutations[types.PUSH](state, TEST_PATH);
expect(state.fullPath).toBe(TEST_PATH);
});
});
});
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