claude rework
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest'
|
||||
import router from '../index'
|
||||
|
||||
describe('router auth guard', () => {
|
||||
beforeEach(() => {
|
||||
localStorage.clear()
|
||||
})
|
||||
|
||||
it('redirects unauthenticated users away from protected routes', async () => {
|
||||
await router.push('/feeds')
|
||||
|
||||
expect(router.currentRoute.value.name).toBe('login')
|
||||
})
|
||||
|
||||
it('lets authenticated users reach protected routes', async () => {
|
||||
localStorage.setItem('user-token', 'abc123')
|
||||
|
||||
await router.push('/feeds')
|
||||
|
||||
expect(router.currentRoute.value.name).toBe('feeds')
|
||||
})
|
||||
|
||||
it('redirects the root path to the feeds route', async () => {
|
||||
localStorage.setItem('user-token', 'abc123')
|
||||
|
||||
await router.push('/')
|
||||
|
||||
expect(router.currentRoute.value.name).toBe('feeds')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user