2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-12 03:52:25 +03:00

fix: call afterNavigation after nextTick (#478)

* fix: afterNavigation

* style: use arrow function
This commit is contained in:
Ricardo Gobbo de Souza
2019-10-28 06:24:42 -03:00
committed by Pim
parent c6b20eb1c0
commit fa12530b3e
2 changed files with 10 additions and 4 deletions
+6 -4
View File
@@ -19,10 +19,12 @@ export function addNavGuards (rootVm) {
})
router.afterEach(() => {
const { metaInfo } = resume(rootVm)
rootVm.$nextTick(() => {
const { metaInfo } = resume(rootVm)
if (metaInfo && isFunction(metaInfo.afterNavigation)) {
metaInfo.afterNavigation(metaInfo)
}
if (metaInfo && isFunction(metaInfo.afterNavigation)) {
metaInfo.afterNavigation(metaInfo)
}
})
})
}
+4
View File
@@ -271,6 +271,8 @@ describe('components', () => {
expect(wrapper.vm.$root._vueMeta.pausing).toBe(true)
guards.after()
expect(afterNavigation).not.toHaveBeenCalled()
await vmTick(wrapper.vm)
expect(afterNavigation).toHaveBeenCalled()
})
@@ -306,6 +308,8 @@ describe('components', () => {
expect(wrapper.vm.$root._vueMeta.pausing).toBe(true)
guards.after()
expect(afterNavigation).not.toHaveBeenCalled()
await vmTick(wrapper.vm)
expect(afterNavigation).toHaveBeenCalled()
})