Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/core/tree.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'
import { DEFAULT_OPTIONS, resolveOptions } from '../options'
import { PrefixTree } from './tree'
import { TreeNodeType } from './treeNodeValue'
import { TreeNodeType, type TreeRouteParam } from './treeNodeValue'
import { resolve } from 'pathe'
import { mockWarn } from '../../tests/vitest-mock-warn'

Expand Down Expand Up @@ -419,6 +419,25 @@ describe('Tree', () => {
expect(node.fullPath).toBe('/custom-child')
})

// https://github.com/posva/unplugin-vue-router/pull/597
// added because in Nuxt the result was different
it('does not contain duplicated params when a child route overrides the path', () => {
const tree = new PrefixTree(RESOLVED_OPTIONS)
tree.insert('[a]', '[a].vue')
const node = tree.insert('[a]/b', '[a]/b.vue')
node.value.setOverride('', {
path: '/:a()/new-b',
})
expect(node.params).toHaveLength(1)
expect(node.params[0]).toEqual({
paramName: 'a',
isSplat: false,
modifier: '',
optional: false,
repeatable: false,
} satisfies TreeRouteParam)
})

it('removes trailing slash from path but not from name', () => {
const tree = new PrefixTree(RESOLVED_OPTIONS)
tree.insert('a/index', 'a/index.vue')
Expand Down