From 2d8072a05b1422d53f3f83965b01e11d89ded380 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 25 Aug 2025 21:18:25 +0200 Subject: [PATCH] test: catch all --- .../matchers/matcher-pattern.spec.ts | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) 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() -- 2.47.3