functional.spec.js 636 B

123456789101112131415161718192021222324
  1. import Vue from 'vue'
  2. describe('Options functional', () => {
  3. it('should work', done => {
  4. const vm = new Vue({
  5. data: { test: 'foo' },
  6. template: '<div><wrap :msg="test">bar</wrap></div>',
  7. components: {
  8. wrap: {
  9. functional: true,
  10. props: ['msg'],
  11. render (h, props, children) {
  12. return h('div', null, [props.msg, ' '].concat(children))
  13. }
  14. }
  15. }
  16. }).$mount()
  17. expect(vm.$el.innerHTML).toBe('<div>foo bar</div>')
  18. vm.test = 'qux'
  19. waitForUpdate(() => {
  20. expect(vm.$el.innerHTML).toBe('<div>qux bar</div>')
  21. }).then(done)
  22. })
  23. })