observable.spec.ts 729 B

12345678910111213141516171819202122232425262728293031323334
  1. import Vue from 'vue'
  2. describe('Global API: observable', () => {
  3. it('should work', done => {
  4. const state = Vue.observable({
  5. count: 0
  6. })
  7. const app = new Vue({
  8. render(h) {
  9. return h('div', [
  10. h('span', state.count),
  11. h(
  12. 'button',
  13. {
  14. on: {
  15. click: () => {
  16. state.count++
  17. }
  18. }
  19. },
  20. '+'
  21. )
  22. ])
  23. }
  24. }).$mount()
  25. expect(app.$el.querySelector('span').textContent).toBe('0')
  26. app.$el.querySelector('button').click()
  27. waitForUpdate(() => {
  28. expect(app.$el.querySelector('span').textContent).toBe('1')
  29. }).then(done)
  30. })
  31. })