From: Eduardo San Martin Morote Date: Tue, 1 Sep 2020 08:27:55 +0000 (+0200) Subject: test: add navigation type tests X-Git-Tag: v4.0.0-beta.8~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d6d454c60e0276fe6262cb43befac288d26fa18;p=thirdparty%2Fvuejs%2Frouter.git test: add navigation type tests --- diff --git a/test-dts/navigationGuards.test-d.ts b/test-dts/navigationGuards.test-d.ts new file mode 100644 index 00000000..66e83da1 --- /dev/null +++ b/test-dts/navigationGuards.test-d.ts @@ -0,0 +1,37 @@ +import { createRouter, createWebHistory, expectType } from './index' +import { NavigationFailure } from 'dist/vue-router' + +const router = createRouter({ + history: createWebHistory(), + routes: [], +}) + +router.beforeEach((to, from) => { + return { path: '/' } +}) + +router.beforeEach((to, from) => { + return '/' +}) + +router.beforeEach((to, from) => { + return false +}) + +// @ts-expect-error +router.beforeEach((to, from, next) => { + return Symbol('not supported') +}) +// @ts-expect-error +router.beforeEach(() => { + return Symbol('not supported') +}) + +router.beforeEach((to, from, next) => { + // @ts-expect-error + next(Symbol('not supported')) +}) + +router.afterEach((to, from, failure) => { + expectType(failure) +})