ray-template/__test__/hooks/useVueRouter.spec.ts
XiaoDaiGua-Ray 403fdd589a feat!: rebuild Ray Template as a monorepo
Share workspace packages between Ray Admin and the interactive docs.

BREAKING CHANGE: v6 is a new major line. v5 stays on legacy/v5.
2026-11-04 14:01:28 +08:00

23 lines
823 B
TypeScript

import { useVueRouter } from '../../apps/admin/src/hooks/web/useVueRouter'
import { router } from '../../apps/admin/src/router'
it('shares the live router outside setup and exposes the current route after navigation', async () => {
const a = useVueRouter()
const b = useVueRouter()
const remove = router.addRoute({ path: '/router-hook-test', component: {} })
try {
expect(a.router).toBe(router)
expect(b.router.currentRoute).toBe(a.router.currentRoute)
await a.router.push('/router-hook-test?source=spec')
expect(b.router.currentRoute.value).toMatchObject({
path: '/router-hook-test',
query: { source: 'spec' },
})
await b.router.replace('/router-hook-test?source=replace')
expect(a.router.currentRoute.value.query.source).toBe('replace')
} finally {
remove()
}
})