/** @type {import('../../src/types').RouteRecord[]} */
const routes = [
{ path: '/', component: Home },
+ { path: '/home', component: Home, beforeEnter },
{ path: '/foo', component: Foo },
{
path: '/guard/:n',
expect(beforeEnter).toHaveBeenCalledTimes(1)
})
+ it('calls beforeEnter different records, same component', async () => {
+ const router = createRouter({ routes })
+ beforeEnter.mockImplementationOnce(noGuard)
+ await router.push('/')
+ expect(beforeEnter).not.toHaveBeenCalled()
+ await router[navigationMethod]('/home')
+ expect(beforeEnter).toHaveBeenCalledTimes(1)
+ })
+
it('does not call beforeEnter guard if we were already on the page', async () => {
const router = createRouter({ routes })
beforeEnter.mockImplementation(noGuard)