Parcourir la source

test functional auto props with render fn

Evan You il y a 9 ans
Parent
commit
561bb467ba
1 fichiers modifiés avec 15 ajouts et 8 suppressions
  1. 15 8
      test/unit/features/options/functional.spec.js

+ 15 - 8
test/unit/features/options/functional.spec.js

@@ -23,18 +23,25 @@ describe('Options functional', () => {
   })
 
   it('should expose all props when not declared', done => {
+    const fn = {
+      functional: true,
+      render (h, { props }) {
+        return h('div', `${props.msg} ${props.kebabMsg}`)
+      }
+    }
+
     const vm = new Vue({
       data: { test: 'foo' },
-      template: '<div><wrap :msg="test" kebab-msg="bar"></wrap></div>',
-      components: {
-        wrap: {
-          functional: true,
-          render (h, { props }) {
-            return h('div', `${props.msg} ${props.kebabMsg}`)
-          }
-        }
+      render (h) {
+        return h('div', [
+          h(fn, {
+            props: { msg: this.test },
+            attrs: { 'kebab-msg': 'bar' }
+          })
+        ])
       }
     }).$mount()
+
     expect(vm.$el.innerHTML).toBe('<div>foo bar</div>')
     vm.test = 'qux'
     waitForUpdate(() => {