Skip to content

Commit ee04db2

Browse files
committed
test: resolver
1 parent 7e8027b commit ee04db2

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`generateRouteResolver > encodes special characters in route resolver paths 1`] = `
4+
"
5+
const __route_0 = normalizeRouteRecord({
6+
name: '/café',
7+
path: new MatcherPatternPathStatic('/caf%C3%A9'),
8+
components: {
9+
'default': () => import('café.vue')
10+
},
11+
})
12+
13+
const __route_1 = normalizeRouteRecord({
14+
name: '/my page',
15+
path: new MatcherPatternPathStatic('/my%20page'),
16+
components: {
17+
'default': () => import('my page.vue')
18+
},
19+
})
20+
21+
const __route_2 = normalizeRouteRecord({
22+
name: '/users/hello world',
23+
path: new MatcherPatternPathStatic('/users/hello%20world'),
24+
components: {
25+
'default': () => import('users/hello world.vue')
26+
},
27+
})
28+
29+
export const resolver = createFixedResolver([
30+
__route_2, // /users/hello%20world
31+
__route_0, // /caf%C3%A9
32+
__route_1, // /my%20page
33+
])
34+
"
35+
`;

src/codegen/generateRouteResolver.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,4 +904,20 @@ describe('generateRouteResolver', () => {
904904
"
905905
`)
906906
})
907+
908+
it('encodes special characters in route resolver paths', () => {
909+
const tree = new PrefixTree(DEFAULT_OPTIONS)
910+
tree.insert('my page', 'my page.vue')
911+
tree.insert('users/hello world', 'users/hello world.vue')
912+
tree.insert('café', 'café.vue')
913+
914+
const resolver = generateRouteResolver(
915+
tree,
916+
DEFAULT_OPTIONS,
917+
new ImportsMap(),
918+
new Map()
919+
)
920+
921+
expect(resolver).toMatchSnapshot()
922+
})
907923
})

0 commit comments

Comments
 (0)