{ path: '/', component: components.Home },
{ path: '/redirect', redirect: '/' },
{ path: '/foo', component: components.Foo, name: 'Foo' },
+ // prevent the log of no match warnings
+ { path: '/:pathMatch(.*)', component: components.Home },
]
const onError = jest.fn()
}
describe('Router', () => {
+ mockWarn()
+
beforeAll(() => {
createDom()
})
await router.push('/me-neither')
expect(router.currentRoute.value).toMatchObject({ matched: [] })
expect(spy).toHaveBeenCalledTimes(1)
+ expect('No match found').toHaveBeenWarnedTimes(2)
})
it('casts number params to string', async () => {
})
describe('Warnings', () => {
- mockWarn()
-
it.skip('avoid infinite redirection loops', async () => {
const history = createMemoryHistory()
let calls = 0
name: undefined,
matched: [],
})
+ expect('No match found').toHaveBeenWarned()
router.addRoute({
path: '/new-route',
component: components.Foo,
name: undefined,
matched: [],
})
+ expect('No match found').toHaveBeenWarned()
let removeRoute: (() => void) | undefined
router.addRoute({
path: '/dynamic',
})
// navigate again
await router.replace('/new/child')
+ expect('No match found').toHaveBeenWarned()
expect(router.currentRoute.value).toMatchObject({
name: 'new-child',
})
name: undefined,
matched: [],
})
+ expect('No match found').toHaveBeenWarned()
})
it('can reroute when removing route', async () => {