]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: more
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 8 Aug 2025 20:07:49 +0000 (22:07 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 8 Aug 2025 20:07:49 +0000 (22:07 +0200)
packages/router/src/experimental/route-resolver/matchers/matcher-pattern.spec.ts
packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts

index fdfd00bab44ce1efcc2ab2582f34a10e4f2be298..5ddf274f1355eadc05ae61ca88599bf2aa389307 100644 (file)
@@ -195,4 +195,26 @@ describe('MatcherPatternPathCustom', () => {
     expect(pattern.build({ teamId: ['123', '456'] })).toBe('/teams/123/456/b')
     expect(pattern.build({ teamId: [] })).toBe('/teams/b')
   })
+
+  it('multiple params', () => {
+    const pattern = new MatcherPatternPathCustomParams(
+      /^\/teams\/([^/]+?)\/([^/]+?)$/i,
+      {
+        teamId: {},
+        otherId: {},
+      },
+      ['teams', 0, 0]
+    )
+
+    expect(pattern.match('/teams/123/456')).toEqual({
+      teamId: '123',
+      otherId: '456',
+    })
+    expect(() => pattern.match('/teams/123')).toThrow()
+    expect(() => pattern.match('/teams/123/456/c')).toThrow()
+    expect(() => pattern.match('/teams/')).toThrow()
+    expect(pattern.build({ teamId: '123', otherId: '456' })).toBe(
+      '/teams/123/456'
+    )
+  })
 })
index 866114cb037b623c94a102227622d3d32388b160..00ce26bdf683b1382fdde41677e6a9d50c6e21c7 100644 (file)
@@ -208,7 +208,7 @@ interface MatcherPatternPathCustomParamOptions<
   repeat?: boolean
   // TODO: not needed because in the regexp, the value is undefined if the group is optional and not given
   optional?: boolean
-  parser: Param_GetSet<TIn, TOut>
+  parser?: Param_GetSet<TIn, TOut>
 }
 
 /**