]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: move warning test to its own spec
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 6 Aug 2020 14:13:33 +0000 (16:13 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 6 Aug 2020 14:13:33 +0000 (16:13 +0200)
__tests__/router.spec.ts
__tests__/warnings.spec.ts

index 9fd384983685921bfc07673ac47131a2648d733f..e45dca1297dc739c46b5a66cc139dbac05e092e3 100644 (file)
@@ -352,36 +352,6 @@ describe('Router', () => {
     expect(router.currentRoute.value.path).toBe('/add')
   })
 
-  describe('Warnings', () => {
-    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)
-      })
-      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('warns if `next` is called twice', async () => {
-      const { router } = await newRouter()
-      router.beforeEach((to, from, next) => {
-        next()
-        next()
-      })
-      await router.push('/foo')
-      expect(
-        'It should be called exactly one time in each navigation guard'
-      ).toHaveBeenWarned()
-    })
-  })
-
   describe('alias', () => {
     it('does not navigate to alias if already on original record', async () => {
       const { router } = await newRouter()
index 5cba0f90fd05f1aeebc26de642effe285e3e7618..4dfa8ac5ca3599ab28388883e0204debfc9db389 100644 (file)
@@ -207,4 +207,22 @@ describe('warnings', () => {
       'Detected an infinite redirection in a navigation guard when going from "/" to "/b"'
     ).toHaveBeenWarned()
   })
+
+  it('warns if `next` is called twice', async () => {
+    const router = createRouter({
+      history: createMemoryHistory(),
+      routes: [
+        { path: '/', component },
+        { path: '/foo', component },
+      ],
+    })
+    router.beforeEach((to, from, next) => {
+      next()
+      next()
+    })
+    await router.push('/foo')
+    expect(
+      'It should be called exactly one time in each navigation guard'
+    ).toHaveBeenWarned()
+  })
 })