router
router copied to clipboard
Child routes are not validated properly
There are two issues with the same feature:
- When I specify
childrenproperty of a route as a non-array in top-level route, I get an error explaining me that I am wrong:
Test:
it('children is specified as an object, not array', async() => {
router.setRoutes([{
path: '/a',
children:
{path: '/b', component: 'x-b'}
}]);
await router.render('/a/b');
});
Actual:
[Vaadin.Router] Expected route config "/a" to include either "component", "redirect", "bundle" or "action" function but none found.
Expected:
router telling me that I should declare children as an array of objects, not objects.
Alternatively, since we have plenty of APIs already that call toArray method in such cases (for instance, setRoutes method, router can wrap this into the array for me automatically.
=========
- When I specify
childrenproperty of a route as a non-array in child route, it is not validated at all.
Test:
it('child route is defined wrong', async() => {
router.setRoutes([{
path: '/a',
children: [
{path: '/b', children: {path: '/c', component: 'x-c'}}
]
}]);
await router.render('/a/b/c');
});
Actual:
Page not found (/a/b/c)
Expected: same error message as above, but for the child route
This can be a part of #171