2018-09-20 11:43:27 +08:00
|
|
|
;(global as any).__COMPAT__ = true
|
|
|
|
|
2018-11-02 13:21:38 +08:00
|
|
|
import Vue from '../src/index'
|
2018-09-20 11:43:27 +08:00
|
|
|
|
|
|
|
describe('2.x compat build', async () => {
|
|
|
|
test('should work', async () => {
|
|
|
|
const root = document.createElement('div')
|
|
|
|
document.body.appendChild(root)
|
|
|
|
|
2018-11-09 09:08:28 +08:00
|
|
|
const mounted = jest.fn()
|
|
|
|
const updated = jest.fn()
|
|
|
|
|
2018-10-10 01:59:30 +08:00
|
|
|
const instance = new Vue({
|
2018-09-20 11:43:27 +08:00
|
|
|
data() {
|
|
|
|
return { count: 0 }
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
change() {
|
|
|
|
this.count++
|
|
|
|
}
|
|
|
|
},
|
|
|
|
render(h: any) {
|
|
|
|
return h('div', this.count)
|
2018-11-09 09:08:28 +08:00
|
|
|
},
|
|
|
|
mounted,
|
|
|
|
updated
|
2018-09-20 11:43:27 +08:00
|
|
|
}).$mount(root)
|
|
|
|
|
|
|
|
expect(instance.count).toBe(0)
|
|
|
|
expect(root.textContent).toBe('0')
|
2018-11-09 09:08:28 +08:00
|
|
|
expect(mounted).toHaveBeenCalled()
|
2018-09-20 11:43:27 +08:00
|
|
|
|
|
|
|
instance.change()
|
|
|
|
expect(instance.count).toBe(1)
|
|
|
|
await Vue.nextTick()
|
|
|
|
expect(root.textContent).toBe('1')
|
2018-11-09 09:08:28 +08:00
|
|
|
expect(updated).toHaveBeenCalled()
|
2018-09-20 11:43:27 +08:00
|
|
|
})
|
|
|
|
})
|