import { createRouterMatcher } from '../../src/matcher'
import { MatcherLocation } from '../../src/types'
+import { mockWarn } from 'jest-mock-warn'
const currentLocation = { path: '/' } as MatcherLocation
// @ts-ignore
expect(matcher.getRecordMatcher('child')).toBe(undefined)
})
+
+ describe('warnings', () => {
+ mockWarn()
+
+ // TODO: add warnings for invalid records
+ it.skip('warns if alias is missing a required param', () => {
+ createRouterMatcher([{ path: '/:id', alias: '/no-id', component }], {})
+ expect('TODO').toHaveBeenWarned()
+ })
+ })
})
expect(router.currentRoute.value.hash).toBe('#two')
})
+ it('fails if required params are missing', async () => {
+ const { router } = await newRouter()
+ await expect(
+ router.push({ name: 'Param', params: {} })
+ ).rejects.toThrowError(/missing required param "p"/i)
+ })
+
describe('alias', () => {
it('does not navigate to alias if already on original record', async () => {
const { router } = await newRouter()
// if we mount, there is a matched record
matchedRoute.value!.instances[unref(options.name)] = viewRef.value
// TODO: trigger beforeRouteEnter hooks
+ // TODO: watch name to update the instance record
}
return (attrs: SetupContext['attrs']) => {