})
})
- describe('matcher', () => {
- // TODO: rewrite after redirect refactor
- it.skip('handles one redirect from route record', async () => {
+ describe('redirect', () => {
+ it('handles one redirect from route record', async () => {
const history = createMemoryHistory()
const router = createRouter({ history, routes })
const loc = await router.push('/to-foo')
})
})
- // TODO: rewrite after redirect refactor
- it.skip('drops query and params on redirect if not provided', async () => {
+ it('handles a double redirect from route record', async () => {
+ const history = createMemoryHistory()
+ const router = createRouter({ history, routes })
+ const loc = await router.push('/to-foo2')
+ expect(loc.name).toBe('Foo')
+ expect(loc.redirectedFrom).toMatchObject({
+ path: '/to-foo2',
+ })
+ })
+
+ it('drops query and params on redirect if not provided', async () => {
const history = createMemoryHistory()
const router = createRouter({ history, routes })
const loc = await router.push('/to-foo?hey=foo#fa')
})
})
- // TODO: rewrite after redirect refactor
- it.skip('allows object in redirect', async () => {
+ it('allows object in redirect', async () => {
const history = createMemoryHistory()
const router = createRouter({ history, routes })
const loc = await router.push('/to-foo-named')
})
})
- // TODO: rewrite after redirect refactor
- it.skip('can pass on query and hash when redirecting', async () => {
+ it('can pass on query and hash when redirecting', async () => {
const history = createMemoryHistory()
const router = createRouter({ history, routes })
const loc = await router.push('/inc-query-hash?n=3#fa')
})
expect(loc.redirectedFrom).toMatchObject({
fullPath: '/inc-query-hash?n=3#fa',
+ query: { n: '3' },
+ hash: '#fa',
path: '/inc-query-hash',
})
})