From 1d75ff3e9da99d5f126e35ad4cd141541726bf1b Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Wed, 22 Apr 2020 14:43:34 +0200 Subject: [PATCH] test: add pending tests --- __tests__/router.spec.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/__tests__/router.spec.ts b/__tests__/router.spec.ts index 67375a35..d3956808 100644 --- a/__tests__/router.spec.ts +++ b/__tests__/router.spec.ts @@ -7,6 +7,9 @@ import { RouteLocationRaw, START_LOCATION_NORMALIZED, } from '../src/types' +import { mockWarn } from 'jest-mock-warn' + +declare var __DEV__: boolean const routes: RouteRecordRaw[] = [ { path: '/', component: components.Home, name: 'home' }, @@ -295,6 +298,29 @@ describe('Router', () => { expect(() => router.resolve({ name: 'r2', params: {} })).not.toThrow() }) + describe('Warnings', () => { + mockWarn() + + it.skip('avoid infinite redirection loops', async () => { + const history = createMemoryHistory() + let calls = 0 + const beforeEnter = jest.fn((to, from, next) => { + if (++calls > 1000) throw new Error('1000 calls') + next(to.path) + }) + console.log('dev', __DEV__) + const { router } = await newRouter({ + history, + routes: [{ path: '/foo', component: components.Home, beforeEnter }], + }) + await expect(router.push('/foo')).resolves.toBe(undefined) + }) + + it.todo('avoid infinite redirection loops when doing router.back()') + + it.todo('warns if `next` is called twice') + }) + describe('alias', () => { it('does not navigate to alias if already on original record', async () => { const { router } = await newRouter() -- 2.39.5