Skip to content

Commit c55db28

Browse files
committed
test: update typed router test
1 parent cb1dade commit c55db28

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/typed-router.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ describe('typed router integration', () => {
1111
await x('nuxt', ['prepare', rootDir])
1212
const typedRouterDtsFile = resolve(rootDir, '.nuxt/types/typed-router.d.ts')
1313
const typedRouterDts = readFileSync(typedRouterDtsFile, 'utf8')
14-
expect(typedRouterDts).toContain(`'param-id-view-custom': RouteRecordInfo<'param-id-view-custom', '/param/:id()/view-custom', { id: ParamValue<true> }, { id: ParamValue<false> }>,`)
15-
expect(typedRouterDts).not.toContain(`'param-id-view-custom': RouteRecordInfo<'param-id-view-custom', '/param/:id()/view-custom', { id: ParamValue<true>, id: ParamValue<true> }, { id: ParamValue<false>, id: ParamValue<false> }>,`)
14+
// Check for the route definition (accommodates both single-line and multi-line formatting)
15+
expect(typedRouterDts).toMatch(/'param-id-view-custom':\s*RouteRecordInfo<\s*'param-id-view-custom',\s*'\/param\/:id\(\)\/view-custom',\s*\{\s*id:\s*ParamValue<true>\s*\},\s*\{\s*id:\s*ParamValue<false>\s*\}/)
16+
// Ensure params are not duplicated
17+
expect(typedRouterDts).not.toMatch(/\{\s*id:\s*ParamValue<\w+>,\s*id:\s*ParamValue<\w+>\s*\}/)
1618
})
1719
})

0 commit comments

Comments
 (0)