import { describe, it, expect } from 'vitest' import router, { FRONT_DOOR } from '../src/router.js' describe('router', () => { it('FRONT_DOOR defaults to /showcase', () => { expect(FRONT_DOOR).toBe('/showcase') }) it('/ redirects to FRONT_DOOR', async () => { // resolve() does not follow redirects (they apply on navigation), so // actually navigate and assert the resulting route. await router.push('/') expect(router.currentRoute.value.path).toBe(FRONT_DOOR) }) it('gallery is reachable at /gallery', () => { expect(router.resolve('/gallery').name).toBe('gallery') }) it('showcase, artist resolve to named routes', () => { expect(router.resolve('/showcase').name).toBe('showcase') expect(router.resolve('/artist/some-slug').name).toBe('artist') expect(router.resolve('/artist/some-slug').params.slug).toBe('some-slug') }) it('browse hub is reachable and old axis paths redirect into its tabs', async () => { expect(router.resolve('/browse').name).toBe('browse') await router.push('/tags') expect(router.currentRoute.value.name).toBe('browse') expect(router.currentRoute.value.query.tab).toBe('tags') await router.push('/artists') expect(router.currentRoute.value.query.tab).toBe('artists') // A posts deep link survives the redirect into the hub tab. await router.push({ path: '/posts', query: { post_id: '7' } }) expect(router.currentRoute.value.name).toBe('browse') expect(router.currentRoute.value.query.tab).toBe('posts') expect(router.currentRoute.value.query.post_id).toBe('7') }) it('series-read is an immersive route', () => { const r = router.resolve('/series/5/read') expect(r.name).toBe('series-read') expect(r.meta.immersive).toBe(true) }) })