expect(() => matcher.match({ c: 'invalid' })).toThrow(MatchMiss)
})
+ it('falls back to default on parser error even when required', () => {
+ const matcher = new MatcherPatternQueryParam(
+ 'count',
+ 'c',
+ 'value',
+ PARAM_PARSER_INT,
+ 0, // default value
+ true // required
+ )
+ // Invalid value should fallback to default instead of throwing
+ expect(matcher.match({ c: 'invalid' })).toEqual({ count: 0 })
+ })
+
it('returns empty array for missing optional param with array format', () => {
const matcher = new MatcherPatternQueryParam(
'items',
`)
})
+ it('generates query param with required and default', () => {
+ const node = new PrefixTree(DEFAULT_OPTIONS).insert('a', 'a.vue')
+ node.value.setEditOverride('params', {
+ query: { page: { parser: 'int', default: '1', required: true } },
+ })
+ expect(
+ generateRouteRecordQuery({ importsMap, node, paramParsersMap: new Map() })
+ ).toMatchInlineSnapshot(`
+ "query: [
+ new MatcherPatternQueryParam('page', 'page', 'value', PARAM_PARSER_INT, 1, true)
+ ],"
+ `)
+ })
+
it('generates mixed query params with different configurations', () => {
const node = new PrefixTree(DEFAULT_OPTIONS).insert('a', 'a.vue')
node.value.setEditOverride('params', {