mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
test logout action in store
This commit is contained in:
parent
544c221fb9
commit
7c49600df6
@ -23,7 +23,7 @@ export const mutations = {
|
||||
export const actions = {
|
||||
logout: ({ commit, state }) => {
|
||||
commit('token', null)
|
||||
localStorage.clear()
|
||||
window.localStorage.clear()
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
import { mutations } from './store'
|
||||
import store, { mutations, actions } from './store'
|
||||
|
||||
const { token, openCreationsPlus, openCreationsMinus, resetOpenCreations } = mutations
|
||||
const { logout } = actions
|
||||
|
||||
const CONFIG = {
|
||||
DEBUG_DISABLE_AUTH: true,
|
||||
}
|
||||
|
||||
describe('Vuex store', () => {
|
||||
describe('mutations', () => {
|
||||
@ -36,4 +41,43 @@ describe('Vuex store', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('actions', () => {
|
||||
describe('logout', () => {
|
||||
const windowStorageMock = jest.fn()
|
||||
const commit = jest.fn()
|
||||
const state = {}
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks()
|
||||
window.localStorage.clear = windowStorageMock
|
||||
})
|
||||
|
||||
it('deletes the token in store', () => {
|
||||
logout({ commit, state })
|
||||
expect(commit).toBeCalledWith('token', null)
|
||||
})
|
||||
|
||||
it.skip('clears the window local storage', () => {
|
||||
expect(windowStorageMock).toBeCalled()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('state', () => {
|
||||
describe('authentication enabled', () => {
|
||||
it('has no token', () => {
|
||||
expect(store.state.token).toBe(null)
|
||||
})
|
||||
})
|
||||
|
||||
describe('authentication enabled', () => {
|
||||
beforeEach(() => {
|
||||
CONFIG.DEBUG_DISABLE_AUTH = false
|
||||
})
|
||||
|
||||
it.skip('has a token', () => {
|
||||
expect(store.state.token).toBe('validToken')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user