-
-
Notifications
You must be signed in to change notification settings - Fork 103
fix: remove componentless routes from routes
in _RouteFileInfoMap
#686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,4 +108,65 @@ describe('generateRouteFileInfoMap', () => { | |
}" | ||
`) | ||
}) | ||
|
||
it('does not contain routes without components', () => { | ||
const tree = new PrefixTree(DEFAULT_OPTIONS) | ||
tree.insert('optional/[[id]]', 'optional/[[id]].vue') | ||
tree.insert( | ||
'optional-repeatable/[[id]]+', | ||
'optional-repeatable/[[id]]+.vue' | ||
) | ||
tree.insert('repeatable/[id]+', 'repeatable/[id]+.vue') | ||
|
||
expect(formatExports(generateRouteFileInfoMap(tree, { root: '' }))) | ||
.toMatchInlineSnapshot(` | ||
"export interface _RouteFileInfoMap { | ||
'optional/[[id]].vue': { | ||
routes: '/optional/[[id]]' | ||
views: never | ||
} | ||
'optional-repeatable/[[id]]+.vue': { | ||
routes: '/optional-repeatable/[[id]]+' | ||
views: never | ||
} | ||
'repeatable/[id]+.vue': { | ||
routes: '/repeatable/[id]+' | ||
views: never | ||
} | ||
}" | ||
`) | ||
}) | ||
|
||
it('does not contain nested routes without components', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @posva But this one only passes after the change in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I think I get it! In
Only after the change I made, those componentless routes are not included in the parent route's |
||
const tree = new PrefixTree(DEFAULT_OPTIONS) | ||
tree.insert('parent', 'parent.vue') | ||
tree.insert('parent/optional/[[id]]', 'parent/optional/[[id]].vue') | ||
tree.insert( | ||
'parent/optional-repeatable/[[id]]+', | ||
'parent/optional-repeatable/[[id]]+.vue' | ||
) | ||
tree.insert('parent/repeatable/[id]+', 'parent/repeatable/[id]+.vue') | ||
|
||
expect(formatExports(generateRouteFileInfoMap(tree, { root: '' }))) | ||
.toMatchInlineSnapshot(` | ||
"export interface _RouteFileInfoMap { | ||
'parent.vue': { | ||
routes: '/parent' | '/parent/optional/[[id]]' | '/parent/optional-repeatable/[[id]]+' | '/parent/repeatable/[id]+' | ||
views: 'default' | ||
} | ||
'parent/optional/[[id]].vue': { | ||
routes: '/parent/optional/[[id]]' | ||
views: never | ||
} | ||
'parent/optional-repeatable/[[id]]+.vue': { | ||
routes: '/parent/optional-repeatable/[[id]]+' | ||
views: never | ||
} | ||
'parent/repeatable/[id]+.vue': { | ||
routes: '/parent/repeatable/[id]+' | ||
views: never | ||
} | ||
}" | ||
`) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@posva This test already passed before my change in
generateRouteFileInfoMap.ts