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') }) })