render-proxy.spec.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import Vue from 'vue'
  2. if (typeof Proxy !== 'undefined') {
  3. describe('render proxy', () => {
  4. it('should warn missing property in render fns with `with`', () => {
  5. new Vue({
  6. template: `<div>{{ a }}</div>`
  7. }).$mount()
  8. expect(`Property or method "a" is not defined`).toHaveBeenWarned()
  9. })
  10. it('should warn missing property in render fns without `with`', () => {
  11. const render = function (h) {
  12. return h('div', [this.a])
  13. }
  14. render._withStripped = true
  15. new Vue({
  16. render
  17. }).$mount()
  18. expect(`Property or method "a" is not defined`).toHaveBeenWarned()
  19. })
  20. it('should not warn for hand-written render functions', () => {
  21. new Vue({
  22. render (h) {
  23. return h('div', [this.a])
  24. }
  25. }).$mount()
  26. expect(`Property or method "a" is not defined`).not.toHaveBeenWarned()
  27. })
  28. it('support symbols using the `in` operator in hand-written render functions', () => {
  29. const sym = Symbol()
  30. const vm = new Vue({
  31. created () {
  32. this[sym] = 'foo'
  33. },
  34. render (h) {
  35. if (sym in this) {
  36. return h('div', [this[sym]])
  37. }
  38. }
  39. }).$mount()
  40. expect(vm.$el.textContent).toBe('foo')
  41. })
  42. })
  43. }