mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Implement+test auth.isAuthenticated()
This commit is contained in:
parent
679f4bddbe
commit
fec665eaf4
@ -27,6 +27,9 @@ export const mutations = {
|
||||
}
|
||||
|
||||
export const getters = {
|
||||
isAuthenticated(state){
|
||||
return !!state.token
|
||||
},
|
||||
isLoggedIn(state) {
|
||||
return !!(state.user && state.token)
|
||||
},
|
||||
|
||||
14
store/auth.test.js
Normal file
14
store/auth.test.js
Normal file
@ -0,0 +1,14 @@
|
||||
import { getters, mutations, actions } from './auth.js'
|
||||
|
||||
let state
|
||||
|
||||
describe('isAuthenticated', () => {
|
||||
describe('given JWT Bearer token', () => {
|
||||
test('true', () => {
|
||||
state = {
|
||||
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6InUxIiwic2x1ZyI6InBldGVyLWx1c3RpZyIsIm5hbWUiOiJQZXRlciBMdXN0aWciLCJhdmF0YXIiOiJodHRwczovL3MzLmFtYXpvbmF3cy5jb20vdWlmYWNlcy9mYWNlcy90d2l0dGVyL25haXRhbmFtb3Jlbm8vMTI4LmpwZyIsImVtYWlsIjoiYWRtaW5AZXhhbXBsZS5vcmciLCJyb2xlIjoiYWRtaW4iLCJpYXQiOjE1NDUwNjMzODcsImV4cCI6MTYzMTQ2MzM4NywiYXVkIjoiaHR0cHM6Ly9uaXRyby1zdGFnaW5nLmh1bWFuLWNvbm5lY3Rpb24ub3JnIiwiaXNzIjoiaHR0cHM6Ly9hcGktbml0cm8tc3RhZ2luZy5odW1hbi1jb25uZWN0aW9uLm9yZyIsInN1YiI6InUxIn0.BQEoC3J6uRqMvIVfHYmMbmfMR2BudiG5Xvn8mfcc0Kk'
|
||||
}
|
||||
expect(getters.isAuthenticated(state)).toBe(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user