]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: catch all
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 25 Aug 2025 19:18:25 +0000 (21:18 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 25 Aug 2025 19:18:25 +0000 (21:18 +0200)
packages/router/src/experimental/route-resolver/matchers/matcher-pattern.spec.ts

index d0bfbebaccdcb874f1c0a4d0873c264d23040b72..554d93da1ac0452618ab474584d44821dd704745 100644 (file)
@@ -237,8 +237,17 @@ describe('MatcherPatternPathDynamic', () => {
     expect(() => pattern.build({ teamId: [] })).toThrow()
   })
 
-  it.todo('catch all route', () => {
-    // const pattern = new MatcherPatternPathDynamic(
+  it('catch all route', () => {
+    const pattern = new MatcherPatternPathDynamic(
+      /^\/(.*)$/,
+      { pathMatch: [] },
+      [0],
+      null
+    )
+
+    expect(pattern.match('/ok')).toEqual({ pathMatch: 'ok' })
+    expect(pattern.match('/ok/ok/ok')).toEqual({ pathMatch: 'ok/ok/ok' })
+    expect(pattern.match('/')).toEqual({ pathMatch: '' })
   })
 
   it('splat params with prefix', () => {
@@ -347,12 +356,13 @@ describe('MatcherPatternPathDynamic', () => {
     expect(pattern.build({ teamId: '123' })).toBe('/teams/123/')
   })
 
-  it.todo('can have a trailing slash after a static segment', () => {
-    const pattern = new MatcherPatternPathDynamic(/^\/teams\/b\/$/i, {}, [
-      'teams',
-      'b',
-      ['/'],
-    ])
+  it('can have a trailing slash after a static segment', () => {
+    const pattern = new MatcherPatternPathDynamic(
+      /^\/teams\/b\/$/i,
+      {},
+      ['teams', 'b'],
+      true
+    )
 
     expect(pattern.match('/teams/b/')).toEqual({})
     expect(() => pattern.match('/teams/b')).toThrow()