mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
test: add type test for appMiddleware route rules
This commit is contained in:
parent
cac7454702
commit
70669012fb
11
test/fixtures/basic-types/types.ts
vendored
11
test/fixtures/basic-types/types.ts
vendored
@ -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>()
|
||||||
|
Loading…
Reference in New Issue
Block a user