Skip to content

Commit b931c7f

Browse files
committed
test: more
1 parent 27ab8e0 commit b931c7f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,26 @@ describe('MatcherPatternPathCustom', () => {
195195
expect(pattern.build({ teamId: ['123', '456'] })).toBe('/teams/123/456/b')
196196
expect(pattern.build({ teamId: [] })).toBe('/teams/b')
197197
})
198+
199+
it('multiple params', () => {
200+
const pattern = new MatcherPatternPathCustomParams(
201+
/^\/teams\/([^/]+?)\/([^/]+?)$/i,
202+
{
203+
teamId: {},
204+
otherId: {},
205+
},
206+
['teams', 0, 0]
207+
)
208+
209+
expect(pattern.match('/teams/123/456')).toEqual({
210+
teamId: '123',
211+
otherId: '456',
212+
})
213+
expect(() => pattern.match('/teams/123')).toThrow()
214+
expect(() => pattern.match('/teams/123/456/c')).toThrow()
215+
expect(() => pattern.match('/teams/')).toThrow()
216+
expect(pattern.build({ teamId: '123', otherId: '456' })).toBe(
217+
'/teams/123/456'
218+
)
219+
})
198220
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ interface MatcherPatternPathCustomParamOptions<
208208
repeat?: boolean
209209
// TODO: not needed because in the regexp, the value is undefined if the group is optional and not given
210210
optional?: boolean
211-
parser: Param_GetSet<TIn, TOut>
211+
parser?: Param_GetSet<TIn, TOut>
212212
}
213213

214214
/**

0 commit comments

Comments
 (0)