diff --git a/examples/ssr/App.js b/examples/ssr/App.js
index 867eb04..88a32b1 100644
--- a/examples/ssr/App.js
+++ b/examples/ssr/App.js
@@ -8,11 +8,27 @@ Vue.use(VueMeta, {
})
export default function createApp () {
+ const SomeComponent = {
+ name: 'SomeComponent',
+ template: `
`,
+ mounted() {
+ console.log('some mounted')
+ }
+ }
+
const Home = {
+ name: 'home',
+ components: {
+ SomeComponent
+ },
template: ``,
metaInfo: {
title: 'Hello World',
@@ -32,6 +48,7 @@ export default function createApp () {
}
const About = {
+ name: 'About',
template: `
Home
diff --git a/test/unit/components.test.js b/test/unit/components.test.js
index 5d01b20..9dc35e2 100644
--- a/test/unit/components.test.js
+++ b/test/unit/components.test.js
@@ -72,35 +72,39 @@ describe('components', () => {
expect(metaInfo.title).toEqual('Goodbye World')
})
- test('child meta-info removed when child is toggled', () => {
+ test('child meta-info removed when child is toggled', async () => {
const wrapper = mount(GoodbyeWorld, { localVue: Vue })
let metaInfo = getMetaInfo(wrapper.vm)
expect(metaInfo.title).toEqual('Hello World')
wrapper.setData({ childVisible: false })
+ await vmTick(wrapper.vm)
metaInfo = getMetaInfo(wrapper.vm)
expect(metaInfo.title).toEqual('Goodbye World')
wrapper.setData({ childVisible: true })
+ await vmTick(wrapper.vm)
metaInfo = getMetaInfo(wrapper.vm)
expect(metaInfo.title).toEqual('Hello World')
})
- test('child meta-info removed when keep-alive child is toggled', () => {
+ test('child meta-info removed when keep-alive child is toggled', async () => {
const wrapper = mount(KeepAlive, { localVue: Vue })
let metaInfo = getMetaInfo(wrapper.vm)
expect(metaInfo.title).toEqual('Hello World')
wrapper.setData({ childVisible: false })
+ await vmTick(wrapper.vm)
metaInfo = getMetaInfo(wrapper.vm)
expect(metaInfo.title).toEqual('Alive World')
wrapper.setData({ childVisible: true })
+ await vmTick(wrapper.vm)
metaInfo = getMetaInfo(wrapper.vm)
expect(metaInfo.title).toEqual('Hello World')
@@ -230,6 +234,7 @@ describe('components', () => {
expect(changed).toHaveBeenCalledTimes(1)
wrapper.setData({ childVisible: true })
+ await vmTick(wrapper.vm)
jest.runAllTimers()
expect(changed).toHaveBeenCalledTimes(2)
diff --git a/test/unit/plugin.test.js b/test/unit/plugin.test.js
index b4227af..f2249a9 100644
--- a/test/unit/plugin.test.js
+++ b/test/unit/plugin.test.js
@@ -150,7 +150,7 @@ describe('plugin', () => {
warn.mockRestore()
})
- test('updates can be pausing and resumed', async () => {
+ test('updates can be paused and resumed', async () => {
const { batchUpdate: _batchUpdate } = jest.requireActual('../../src/client/update')
const batchUpdateSpy = batchUpdate.mockImplementation(_batchUpdate)
// because triggerUpdate & batchUpdate reside in the same file we cant mock them both,
@@ -195,6 +195,7 @@ describe('plugin', () => {
title = 'second title'
wrapper.setProps({ title })
+ await vmTick(wrapper.vm)
// batchUpdate on normal update
expect(wrapper.vm.$root._vueMeta.initialized).toBe(true)
@@ -206,6 +207,7 @@ describe('plugin', () => {
wrapper.vm.$meta().pause()
title = 'third title'
wrapper.setProps({ title })
+ await vmTick(wrapper.vm)
// no batchUpdate when pausing
expect(wrapper.vm.$root._vueMeta.initialized).toBe(true)
@@ -260,6 +262,8 @@ describe('plugin', () => {
title = 'second title'
wrapper.setProps({ title })
+ await vmTick(wrapper.vm)
+
jest.advanceTimersByTime(2)
expect(refreshSpy).not.toHaveBeenCalled()
jest.advanceTimersByTime(10)