mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-17 14:50:34 +03:00
fix: move addNavGuards check to mounted hook
The addNavGuards check adds the navigation guards when an afterNavigation callback is defined but refreshOnceOnNavigation was not set. As the afterNavigation callback is defined in metaInfo which can be dependent on user data we need to wait until all components are fully mounted before checking if a afterNavigation callback was defined Fixes: #348
This commit is contained in:
@@ -128,7 +128,7 @@ describe('client', () => {
|
||||
expect(context._uid).toBe(wrapper.vm._uid)
|
||||
})
|
||||
|
||||
test('afterNavigation function is called with refreshOnce: true', () => {
|
||||
test('afterNavigation function is called with refreshOnce: true', async () => {
|
||||
const Vue = loadVueMetaPlugin(false, { refreshOnceOnNavigation: true })
|
||||
const afterNavigation = jest.fn()
|
||||
const component = Vue.component('nav-component', {
|
||||
@@ -151,6 +151,8 @@ describe('client', () => {
|
||||
}
|
||||
})
|
||||
|
||||
await vmTick(wrapper.vm)
|
||||
|
||||
expect(guards.before).toBeDefined()
|
||||
expect(guards.after).toBeDefined()
|
||||
|
||||
@@ -161,7 +163,7 @@ describe('client', () => {
|
||||
expect(afterNavigation).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('afterNavigation function is called with refreshOnce: false', () => {
|
||||
test('afterNavigation function is called with refreshOnce: false', async () => {
|
||||
const Vue = loadVueMetaPlugin(false, { refreshOnceOnNavigation: false })
|
||||
const afterNavigation = jest.fn()
|
||||
const component = Vue.component('nav-component', {
|
||||
@@ -184,6 +186,8 @@ describe('client', () => {
|
||||
}
|
||||
})
|
||||
|
||||
await vmTick(wrapper.vm)
|
||||
|
||||
expect(guards.before).toBeDefined()
|
||||
expect(guards.after).toBeDefined()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user