]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: todo
authorEduardo San Martin Morote <posva13@gmail.com>
Sat, 23 Aug 2025 12:59:26 +0000 (14:59 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Sat, 23 Aug 2025 12:59:26 +0000 (14:59 +0200)
packages/router/src/experimental/route-resolver/matchers/matcher-pattern.spec.ts

index 083f2fab00f5bfe78a3cba28b53758e407738c1f..ac28af0a8689affa8a1d03e42da03dd61e4435cc 100644 (file)
@@ -161,6 +161,25 @@ describe('MatcherPatternPathDynamic', () => {
     expect(pattern.build({ teamId: '' })).toBe('/teams/b')
   })
 
+  it.todo('optional param in the end', () => {
+    const pattern = new MatcherPatternPathDynamic(
+      /^\/teams(?:\/([^/]+?))?\/b$/i,
+      {
+        teamId: {},
+      },
+      ['teams', 0, 'b']
+    )
+
+    expect(pattern.match('/teams/b')).toEqual({ teamId: null })
+    expect(pattern.match('/teams/123/b')).toEqual({ teamId: '123' })
+    expect(() => pattern.match('/teams/123/c')).toThrow()
+    expect(() => pattern.match('/teams/123/b/c')).toThrow()
+    expect(() => pattern.match('/teams//b')).toThrow()
+    expect(pattern.build({ teamId: '123' })).toBe('/teams/123/b')
+    expect(pattern.build({ teamId: null })).toBe('/teams/b')
+    expect(pattern.build({ teamId: '' })).toBe('/teams/b')
+  })
+
   it('repeatable param', () => {
     const pattern = new MatcherPatternPathDynamic(
       /^\/teams\/(.+?)\/b$/i,