test: add type test for appMiddleware route rules

This commit is contained in:
Daniel Roe 2024-03-16 15:07:08 -07:00
parent cac7454702
commit 70669012fb
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -107,6 +107,17 @@ describe('middleware', () => {
// @ts-expect-error Invalid middleware // @ts-expect-error Invalid middleware
definePageMeta({ middleware: 'nonexistent' }) definePageMeta({ middleware: 'nonexistent' })
}) })
it('types routeRules', () => {
defineNuxtConfig({
routeRules: {
// @ts-expect-error Invalid middleware
'/nonexistent': { appMiddleware: 'nonexistent' },
// @ts-expect-error ignore global middleware
'/global': { appMiddleware: 'global' },
'/named': { appMiddleware: 'named' }
}
})
})
it('handles adding middleware', () => { it('handles adding middleware', () => {
addRouteMiddleware('example', (to, from) => { addRouteMiddleware('example', (to, from) => {
expectTypeOf(to).toEqualTypeOf<RouteLocationNormalized>() expectTypeOf(to).toEqualTypeOf<RouteLocationNormalized>()