)
})
+ it('can be removed', async () => {
+ const spy = jest.fn()
+ const router = createRouter({ routes })
+ const remove = router.afterEach(spy)
+ remove()
+ await router[navigationMethod]('/foo')
+ expect(spy).not.toHaveBeenCalled()
+ })
+
it('does not call afterEach if navigation is cancelled', async () => {
const spy = jest.fn()
const router = createRouter({ routes })
expect(spy).toHaveBeenCalledTimes(1)
})
+ it('can be removed', async () => {
+ const spy = jest.fn()
+ const router = createRouter({ routes })
+ const remove = router.beforeEach(spy)
+ remove()
+ spy.mockImplementationOnce(noGuard)
+ await router[navigationMethod]('/foo')
+ expect(spy).not.toHaveBeenCalled()
+ })
+
it('does not call beforeEach guard if we were already on the page', async () => {
const spy = jest.fn()
const router = createRouter({ routes })