40 lines
853 B
TypeScript
Raw Normal View History

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