Skip to content

Commit

Permalink
test: add raw path
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed May 2, 2023
1 parent 9bea452 commit 461f247
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/codegen/generateRouteMap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ describe('generateRouteNamedMap', () => {
`)
})

it('handles params from raw routes', () => {
const tree = createPrefixTree(DEFAULT_OPTIONS)
const a = tree.insertParsedPath(':a', 'a.vue')
const b = tree.insertParsedPath(':b()', 'a.vue')
expect(a.name).toBe('/:a')
expect(b.name).toBe('/:b()')
expect(formatExports(generateRouteNamedMap(tree))).toMatchInlineSnapshot(`
"export interface RouteNamedMap {
'/:a': RouteRecordInfo<'/:a', '/:a', { a: ParamValue<true> }, { a: ParamValue<false> }>,
'/:b()': RouteRecordInfo<'/:b()', '/:b()', { b: ParamValue<true> }, { b: ParamValue<false> }>,
}"
`)
})

it('handles nested params in folders', () => {
const tree = createPrefixTree(DEFAULT_OPTIONS)
tree.insert('n/[a]/index.vue') // normal
Expand Down

0 comments on commit 461f247

Please sign in to comment.