Преглед на файлове

add test case for container/replacer attrs with same name

Evan You преди 11 години
родител
ревизия
4c25d1eb03
променени са 1 файла, в които са добавени 28 реда и са изтрити 0 реда
  1. 28 0
      test/unit/specs/compiler/compile_spec.js

+ 28 - 0
test/unit/specs/compiler/compile_spec.js

@@ -242,5 +242,33 @@ if (_.inBrowser) {
       })
     })
 
+    it('should handle container/replacer directives with same name', function () {
+      var parentSpy = jasmine.createSpy()
+      var childSpy = jasmine.createSpy()
+      vm = new Vue({
+        el: el,
+        template:
+          '<div v-component="a" class="a" v-on="click:test(1)"></div>',
+        methods: {
+          test: parentSpy
+        },
+        components: {
+          a: {
+            template: '<div class="b" v-on="click:test(2)"></div>',
+            replace: true,
+            methods: {
+              test: childSpy
+            }
+          }
+        }
+      })
+      expect(vm.$el.firstChild.className).toBe('b a')
+      var e = document.createEvent('HTMLEvents')
+      e.initEvent('click', true, true)
+      vm.$el.firstChild.dispatchEvent(e)
+      expect(parentSpy).toHaveBeenCalledWith(1)
+      expect(childSpy).toHaveBeenCalledWith(2)
+    })
+
   })
 }