feat: typed API client (useApi) and session store (useSession) with the global 401, unverified-403, 429 and offline handling from states.md
This commit is contained in:
1 parent
eed661bb24
commit
12faab7f92
6 files changed
+488
-6
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { useSessionStore } from '@/stores/session'
|
||||
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia())
|
||||
})
|
||||
|
||||
describe('session store clear action', () => {
|
||||
it('resets the session to null and the status to ready regardless of the previous state', () => {
|
||||
const session = useSessionStore()
|
||||
session.session = { verified: true }
|
||||
session.status = 'checking'
|
||||
|
||||
session.clear()
|
||||
|
||||
expect(session.session).toBeNull()
|
||||
expect(session.status).toBe('ready')
|
||||
})
|
||||
})
|
||||
@@ -46,5 +46,10 @@ export const useSessionStore = defineStore('session', () => {
|
||||
return check()
|
||||
}
|
||||
|
||||
return { status, session, check, retry }
|
||||
function clear() {
|
||||
session.value = null
|
||||
status.value = 'ready'
|
||||
}
|
||||
|
||||
return { status, session, check, retry, clear }
|
||||
})
|
||||
Reference in new issue
Block a user