]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: meta object
authorEduardo San Martin Morote <posva13@gmail.com>
Sat, 10 Aug 2019 21:37:09 +0000 (23:37 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Sat, 10 Aug 2019 21:37:12 +0000 (23:37 +0200)
__tests__/guards/global-beforeEach.spec.js

index f09837b0336501bbafb353bec9a85700cdd24021..4317abeaf990f51735fc57f2125084d664eb4c1d 100644 (file)
@@ -225,6 +225,18 @@ describe('router.beforeEach', () => {
         expect(guard2).toHaveBeenCalled()
         expect(router.currentRoute.fullPath).toBe('/foo')
       })
+
+      it('adds meta information', async () => {
+        const spy = jest.fn()
+        const router = createRouter({ routes })
+        router.beforeEach(spy)
+        spy.mockImplementationOnce(noGuard)
+        await router[navigationMethod]('/n/2')
+        expect(spy).toHaveBeenCalledTimes(1)
+        expect(spy).toHaveBeenCalledWith(
+          expect.objectContaining({ meta: { requiresLogin: true } })
+        )
+      })
     })
   })
 })