]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: add pending tests
authorEduardo San Martin Morote <posva13@gmail.com>
Wed, 22 Apr 2020 12:43:34 +0000 (14:43 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Wed, 22 Apr 2020 12:43:34 +0000 (14:43 +0200)
__tests__/router.spec.ts

index 67375a35c0146dc9a58f063e39cf9121c05c1af7..d39568083c158e632d738c3207c2249a09dcaa10 100644 (file)
@@ -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()