)
).toMatchSnapshot()
})
+
+ it('avoids records with children without a component nor name', () => {
+ assertErrorMatch(
+ {
+ path: '/articles',
+ children: [{ path: ':id', components }],
+ },
+ { path: '/articles' }
+ )
+ })
+
+ it('avoids nested records with children without a component nor name', () => {
+ assertErrorMatch(
+ {
+ path: '/app',
+ components,
+ children: [
+ {
+ path: '/articles',
+ children: [{ path: ':id', components }],
+ },
+ ],
+ },
+ { path: '/articles' }
+ )
+ })
+
+ it('can reach a named route with children and no component if named', () => {
+ assertRecordMatch(
+ {
+ path: '/articles',
+ name: 'ArticlesParent',
+ children: [{ path: ':id', components }],
+ },
+ { name: 'ArticlesParent' },
+ { name: 'ArticlesParent', path: '/articles' }
+ )
+ })
})
describe('children', () => {
// parent.children.push(originalRecord)
// }
- insertMatcher(matcher)
+ // Avoid adding a record that doesn't display anything. This allows passing through records without a component to
+ // not be reached and pass through the catch all route
+ if (
+ (matcher.record.components &&
+ Object.keys(matcher.record.components).length) ||
+ matcher.record.name ||
+ matcher.record.redirect
+ ) {
+ insertMatcher(matcher)
+ }
}
return originalMatcher