Skip to content

Commit 744027c

Browse files
committed
test: add redirect
1 parent 92efba7 commit 744027c

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

packages/router/__tests__/router.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ describe('Router', () => {
797797

798798
it('keeps original replace if redirect', async () => {
799799
const history = createMemoryHistory()
800-
const router = createRouter({ history, routes })
800+
const { router } = await newRouter({ history })
801801
await router.push('/search')
802802

803803
await expect(router.replace('/to-foo')).resolves.toEqual(undefined)

packages/router/__tests__/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
RouteLocationNormalized,
1818
} from '../src'
1919
import { _RouteRecordProps } from '../src/typed-routes'
20+
import { type EXPERIMENTAL_Router } from '../src/experimental'
2021

2122
export const tick = (time?: number) =>
2223
new Promise(resolve => {
@@ -32,7 +33,7 @@ export async function ticks(n: number) {
3233

3334
export const delay = (t: number) => new Promise(r => setTimeout(r, t))
3435

35-
export function nextNavigation(router: Router) {
36+
export function nextNavigation(router: Router | EXPERIMENTAL_Router) {
3637
return new Promise((resolve, reject) => {
3738
let removeAfter = router.afterEach((_to, _from, failure) => {
3839
removeAfter()

packages/router/src/experimental/router.spec.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ import {
3535
createFixedResolver,
3636
MatcherPatternPathStatic,
3737
MatcherPatternPathDynamic,
38-
EXPERIMENTAL_RouteRecord_Matchable,
39-
EXPERIMENTAL_RouterOptions,
38+
type EXPERIMENTAL_RouteRecord_Matchable,
39+
type EXPERIMENTAL_RouterOptions,
4040
normalizeRouteRecord,
4141
} from './index'
4242
import {
@@ -1000,8 +1000,11 @@ describe('Experimental Router', () => {
10001000
})
10011001
})
10021002

1003-
it.skip('keeps original replace if redirect', async () => {
1004-
const { router } = await newRouter()
1003+
it('keeps original replace if redirect', async () => {
1004+
const history = createMemoryHistory()
1005+
const { router } = await newRouter({
1006+
history,
1007+
})
10051008
await router.push('/search')
10061009

10071010
await expect(router.replace('/to-foo')).resolves.toEqual(undefined)
@@ -1010,9 +1013,8 @@ describe('Experimental Router', () => {
10101013
redirectedFrom: expect.objectContaining({ path: '/to-foo' }),
10111014
})
10121015

1013-
const navPromise = nextNavigation(router as any)
10141016
history.go(-1)
1015-
await navPromise
1017+
await nextNavigation(router)
10161018
expect(router.currentRoute.value).not.toMatchObject({
10171019
path: '/search',
10181020
})

0 commit comments

Comments
 (0)