diff --git a/admin/src/store/store.js b/admin/src/store/store.js index d67537499..dc168c558 100644 --- a/admin/src/store/store.js +++ b/admin/src/store/store.js @@ -26,6 +26,7 @@ export const mutations = { export const actions = { logout: ({ commit, state }) => { commit('token', null) + commit('moderator', null) window.localStorage.clear() }, } @@ -38,7 +39,7 @@ const store = new Vuex.Store({ ], state: { token: CONFIG.DEBUG_DISABLE_AUTH ? 'validToken' : null, - moderator: { name: 'Dertest Moderator', id: 0 }, + moderator: null, openCreations: 0, }, // Syncronous mutation of the state diff --git a/admin/src/store/store.test.js b/admin/src/store/store.test.js index 4482a46bf..de8a55412 100644 --- a/admin/src/store/store.test.js +++ b/admin/src/store/store.test.js @@ -1,6 +1,6 @@ import store, { mutations, actions } from './store' -const { token, openCreationsPlus, openCreationsMinus, resetOpenCreations } = mutations +const { token, openCreationsPlus, openCreationsMinus, resetOpenCreations, moderator } = mutations const { logout } = actions const CONFIG = { @@ -40,6 +40,14 @@ describe('Vuex store', () => { expect(state.openCreations).toEqual(0) }) }) + + describe('moderator', () => { + it('sets the moderator object in state', () => { + const state = { moderator: null } + moderator(state, { id: 1 }) + expect(state.moderator).toEqual({ id: 1 }) + }) + }) }) describe('actions', () => { @@ -57,6 +65,11 @@ describe('Vuex store', () => { expect(commit).toBeCalledWith('token', null) }) + it('deletes the moderator in store', () => { + logout({ commit, state }) + expect(commit).toBeCalledWith('moderator', null) + }) + it.skip('clears the window local storage', () => { expect(windowStorageMock).toBeCalled() })