]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test(warns): add a warning test when `next` is called twice (#371)
authorzMouse <zmouse@vip.qq.com>
Wed, 15 Jul 2020 12:06:39 +0000 (20:06 +0800)
committerGitHub <noreply@github.com>
Wed, 15 Jul 2020 12:06:39 +0000 (14:06 +0200)
__tests__/router.spec.ts

index e6b8be6d7b535679e1820960a8f4c1d927254121..62c6626d7238cdccef7a9f57f54ef42f305e7da8 100644 (file)
@@ -354,7 +354,17 @@ describe('Router', () => {
 
     it.todo('avoid infinite redirection loops when doing router.back()')
 
-    it.todo('warns if `next` is called twice')
+    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', () => {