Skip to content

Commit 2d8072a

Browse files
committed
test: catch all
1 parent be1679c commit 2d8072a

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

packages/router/src/experimental/route-resolver/matchers/matcher-pattern.spec.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,17 @@ describe('MatcherPatternPathDynamic', () => {
237237
expect(() => pattern.build({ teamId: [] })).toThrow()
238238
})
239239

240-
it.todo('catch all route', () => {
241-
// const pattern = new MatcherPatternPathDynamic(
240+
it('catch all route', () => {
241+
const pattern = new MatcherPatternPathDynamic(
242+
/^\/(.*)$/,
243+
{ pathMatch: [] },
244+
[0],
245+
null
246+
)
247+
248+
expect(pattern.match('/ok')).toEqual({ pathMatch: 'ok' })
249+
expect(pattern.match('/ok/ok/ok')).toEqual({ pathMatch: 'ok/ok/ok' })
250+
expect(pattern.match('/')).toEqual({ pathMatch: '' })
242251
})
243252

244253
it('splat params with prefix', () => {
@@ -347,12 +356,13 @@ describe('MatcherPatternPathDynamic', () => {
347356
expect(pattern.build({ teamId: '123' })).toBe('/teams/123/')
348357
})
349358

350-
it.todo('can have a trailing slash after a static segment', () => {
351-
const pattern = new MatcherPatternPathDynamic(/^\/teams\/b\/$/i, {}, [
352-
'teams',
353-
'b',
354-
['/'],
355-
])
359+
it('can have a trailing slash after a static segment', () => {
360+
const pattern = new MatcherPatternPathDynamic(
361+
/^\/teams\/b\/$/i,
362+
{},
363+
['teams', 'b'],
364+
true
365+
)
356366

357367
expect(pattern.match('/teams/b/')).toEqual({})
358368
expect(() => pattern.match('/teams/b')).toThrow()

0 commit comments

Comments
 (0)