]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: add redirect
authorEduardo San Martin Morote <posva13@gmail.com>
Sat, 18 Oct 2025 08:54:18 +0000 (10:54 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Sat, 18 Oct 2025 08:54:18 +0000 (10:54 +0200)
packages/router/__tests__/router.spec.ts
packages/router/__tests__/utils.ts
packages/router/src/experimental/router.spec.ts

index dee6e8fbae8092e6c9d19d356f645c90c298f431..4327b56040a22732049b7b65a98820c2f7f5de19 100644 (file)
@@ -797,7 +797,7 @@ describe('Router', () => {
 
     it('keeps original replace if redirect', async () => {
       const history = createMemoryHistory()
-      const router = createRouter({ history, routes })
+      const { router } = await newRouter({ history })
       await router.push('/search')
 
       await expect(router.replace('/to-foo')).resolves.toEqual(undefined)
index a6020fc3a22a9906c4d61102761156a2fc1daadf..7967ec6b62004a74109a2165ce778852f001c6a7 100644 (file)
@@ -17,6 +17,7 @@ import {
   RouteLocationNormalized,
 } from '../src'
 import { _RouteRecordProps } from '../src/typed-routes'
+import { type EXPERIMENTAL_Router } from '../src/experimental'
 
 export const tick = (time?: number) =>
   new Promise(resolve => {
@@ -32,7 +33,7 @@ export async function ticks(n: number) {
 
 export const delay = (t: number) => new Promise(r => setTimeout(r, t))
 
-export function nextNavigation(router: Router) {
+export function nextNavigation(router: Router | EXPERIMENTAL_Router) {
   return new Promise((resolve, reject) => {
     let removeAfter = router.afterEach((_to, _from, failure) => {
       removeAfter()
index 116a8fb036e299ae351eb35aa2115fa6e8de4e35..2c44b759cce24c8215b00a0c755e1e1a72927075 100644 (file)
@@ -35,8 +35,8 @@ import {
   createFixedResolver,
   MatcherPatternPathStatic,
   MatcherPatternPathDynamic,
-  EXPERIMENTAL_RouteRecord_Matchable,
-  EXPERIMENTAL_RouterOptions,
+  type EXPERIMENTAL_RouteRecord_Matchable,
+  type EXPERIMENTAL_RouterOptions,
   normalizeRouteRecord,
 } from './index'
 import {
@@ -1000,8 +1000,11 @@ describe('Experimental Router', () => {
       })
     })
 
-    it.skip('keeps original replace if redirect', async () => {
-      const { router } = await newRouter()
+    it('keeps original replace if redirect', async () => {
+      const history = createMemoryHistory()
+      const { router } = await newRouter({
+        history,
+      })
       await router.push('/search')
 
       await expect(router.replace('/to-foo')).resolves.toEqual(undefined)
@@ -1010,9 +1013,8 @@ describe('Experimental Router', () => {
         redirectedFrom: expect.objectContaining({ path: '/to-foo' }),
       })
 
-      const navPromise = nextNavigation(router as any)
       history.go(-1)
-      await navPromise
+      await nextNavigation(router)
       expect(router.currentRoute.value).not.toMatchObject({
         path: '/search',
       })