Explorar o código

Added title prop test

fergaldoyle %!s(int64=10) %!d(string=hai) anos
pai
achega
0061846347
Modificáronse 1 ficheiros con 44 adicións e 0 borrados
  1. 44 0
      test/unit/specs/misc_spec.js

+ 44 - 0
test/unit/specs/misc_spec.js

@@ -269,4 +269,48 @@ describe('Misc', function () {
     })
     expect(hasWarned(__, 'Unknown custom element')).toBe(true)
   })
+
+  it('prefer bound title over static title', function (done) {
+    var el = document.createElement('div')
+    var count = 0
+    var expected = [
+      'bound',
+      'bound',
+      'static',
+      'bound',
+      'bound'
+    ]
+    function check (title) {
+      expect(title).toBe(expected[count])
+      count++
+      if (count === 4) {
+        done()
+      }
+    }
+
+    document.body.appendChild(el)
+
+    new Vue({
+      el: el,
+      template:
+        '<div>\
+          <comp v-bind:title="title"></comp>\
+          <comp title="static" v-bind:title="title"></comp>\
+          <comp title="static"></comp>\
+          <comp :title="title"></comp>\
+          <comp title="static" :title="title"></comp>\
+        </div>',
+      data: {
+        title: 'bound'
+      },
+      components: {
+        comp: {
+          props: ['title'],
+          ready: function () {
+            check(this.title)
+          }
+        }
+      }
+    })
+  })
 })