From: Eduardo San Martin Morote Date: Mon, 25 Aug 2025 19:18:25 +0000 (+0200) Subject: test: catch all X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2d8072a05b1422d53f3f83965b01e11d89ded380;p=thirdparty%2Fvuejs%2Frouter.git test: catch all --- diff --git a/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.spec.ts b/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.spec.ts index d0bfbeba..554d93da 100644 --- a/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.spec.ts +++ b/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.spec.ts @@ -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()