|
1 | 1 | import { describe, expect, it } from 'vitest'
|
2 | 2 | import { DEFAULT_OPTIONS, resolveOptions } from '../options'
|
3 | 3 | import { PrefixTree } from './tree'
|
4 |
| -import { TreeNodeType } from './treeNodeValue' |
| 4 | +import { TreeNodeType, type TreeRouteParam } from './treeNodeValue' |
5 | 5 | import { resolve } from 'pathe'
|
6 | 6 | import { mockWarn } from '../../tests/vitest-mock-warn'
|
7 | 7 |
|
@@ -419,6 +419,25 @@ describe('Tree', () => {
|
419 | 419 | expect(node.fullPath).toBe('/custom-child')
|
420 | 420 | })
|
421 | 421 |
|
| 422 | + // https://github.com/posva/unplugin-vue-router/pull/597 |
| 423 | + // added because in Nuxt the result was different |
| 424 | + it('does not contain duplicated params when a child route overrides the path', () => { |
| 425 | + const tree = new PrefixTree(RESOLVED_OPTIONS) |
| 426 | + tree.insert('[a]', '[a].vue') |
| 427 | + const node = tree.insert('[a]/b', '[a]/b.vue') |
| 428 | + node.value.setOverride('', { |
| 429 | + path: '/:a()/new-b', |
| 430 | + }) |
| 431 | + expect(node.params).toHaveLength(1) |
| 432 | + expect(node.params[0]).toEqual({ |
| 433 | + paramName: 'a', |
| 434 | + isSplat: false, |
| 435 | + modifier: '', |
| 436 | + optional: false, |
| 437 | + repeatable: false, |
| 438 | + } satisfies TreeRouteParam) |
| 439 | + }) |
| 440 | + |
422 | 441 | it('removes trailing slash from path but not from name', () => {
|
423 | 442 | const tree = new PrefixTree(RESOLVED_OPTIONS)
|
424 | 443 | tree.insert('a/index', 'a/index.vue')
|
|
0 commit comments