From 27a33892a261f3f2e3bf267999a66ed8b145e1e0 Mon Sep 17 00:00:00 2001 From: zMouse Date: Wed, 15 Jul 2020 20:06:39 +0800 Subject: [PATCH] test(warns): add a warning test when `next` is called twice (#371) --- __tests__/router.spec.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/__tests__/router.spec.ts b/__tests__/router.spec.ts index e6b8be6d..62c6626d 100644 --- a/__tests__/router.spec.ts +++ b/__tests__/router.spec.ts @@ -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', () => { -- 2.47.3