})
})
+ it('remove children but not parent', () => {
+ const matcher = createRouterMatcher(
+ [{ path: '/', component, name: 'home' }],
+ {}
+ )
+ const remove = matcher.addRoute(
+ { path: 'foo', component, name: 'child' },
+ matcher.getRecordMatcher('home')
+ )
+ remove()
+ expect(matcher.resolve({ path: '/' }, currentLocation)).toMatchObject({
+ name: 'home',
+ })
+ expect(matcher.resolve({ path: '/foo' }, currentLocation)).toMatchObject({
+ name: undefined,
+ matched: [],
+ })
+ })
+
it.todo('remove aliases')
it.todo('remove aliases children')
}).toThrow()
})
- it.todo('removes alias by name')
it('removes children by name', () => {
const matcher = createRouterMatcher([], {})
matcher.addRoute({
})
})
- it.todo('removes children by name from parent')
+ it('removes children by name from parent', () => {
+ const matcher = createRouterMatcher([], {})
+ matcher.addRoute({
+ path: '/',
+ component,
+ name: 'home',
+ children: [
+ // absolute path so it can work out
+ { path: '/about', name: 'child', component },
+ ],
+ })
+
+ matcher.removeRoute('home')
+
+ expect(matcher.resolve({ path: '/about' }, currentLocation)).toMatchObject({
+ name: undefined,
+ matched: [],
+ })
+
+ expect(matcher.getRecordMatcher('child')).toBe(undefined)
+ })
+
+ it.todo('removes alias by name')
it.todo('removes children alias by name')
})