refactor: properly cleanup invalidated jobs

This commit is contained in:
Evan You
2018-11-08 20:08:28 -05:00
parent d39eb6cdbc
commit a95532495a
5 changed files with 130 additions and 79 deletions

View File

@@ -7,6 +7,9 @@ describe('2.x compat build', async () => {
const root = document.createElement('div')
document.body.appendChild(root)
const mounted = jest.fn()
const updated = jest.fn()
const instance = new Vue({
data() {
return { count: 0 }
@@ -18,15 +21,19 @@ describe('2.x compat build', async () => {
},
render(h: any) {
return h('div', this.count)
}
},
mounted,
updated
}).$mount(root)
expect(instance.count).toBe(0)
expect(root.textContent).toBe('0')
expect(mounted).toHaveBeenCalled()
instance.change()
expect(instance.count).toBe(1)
await Vue.nextTick()
expect(root.textContent).toBe('1')
expect(updated).toHaveBeenCalled()
})
})