Просмотр исходного кода

improve async component test case with props and events

Evan You 10 лет назад
Родитель
Сommit
ff6395e493
1 измененных файлов с 11 добавлено и 2 удалено
  1. 11 2
      test/unit/specs/async_component_spec.js

+ 11 - 2
test/unit/specs/async_component_spec.js

@@ -15,14 +15,22 @@ describe('Async components', function () {
   })
 
   it('normal', function (done) {
+    var go = jasmine.createSpy()
     new Vue({
       el: el,
-      template: '<test></test>',
+      template: '<test hi="ok" @ready="go"></test>',
+      methods: {
+        go: go
+      },
       components: {
         test: function (resolve) {
           setTimeout(function () {
             resolve({
-              template: 'ok'
+              props: ['hi'],
+              template: '{{ hi }}',
+              ready: function () {
+                this.$emit('ready')
+              }
             })
             next()
           }, 0)
@@ -31,6 +39,7 @@ describe('Async components', function () {
     })
     function next () {
       expect(el.textContent).toBe('ok')
+      expect(go).toHaveBeenCalled()
       done()
     }
   })