mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
handle moderator in store
This commit is contained in:
parent
257e2e4073
commit
812722c53c
@ -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
|
||||
|
||||
@ -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()
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user