Evan You 12 лет назад
Родитель
Сommit
309ea3d05f
1 измененных файлов с 32 добавлено и 2 удалено
  1. 32 2
      test/unit/specs/directives.js

+ 32 - 2
test/unit/specs/directives.js

@@ -572,11 +572,41 @@ describe('UNIT: Directives', function () {
     describe('component', function () {
         
         it('should work with no args', function () {
-            assert.ok(false)
+            var testId = 'component-test'
+            mock(testId, '<div v-component="' + testId + '"></div>')
+            var t = new Vue({
+                el: '#' + testId,
+                scope: {
+                    msg: '123'
+                },
+                components: {
+                    'component-test': {
+                        template: '<span>{{msg}}</span>'
+                    }
+                }
+            })
+            assert.strictEqual(t.$el.querySelector('span').textContent, '123')
         })
 
         it('should work with arg (passed-in model from parent)', function () {
-            assert.ok(false)
+            var testId = 'component-test-2'
+            mock(testId, '<div v-component="' + testId + ':options.test"></div>')
+            var t = new Vue({
+                el: '#' + testId,
+                scope: {
+                    options: {
+                        test: {
+                            msg: '123'
+                        }
+                    }
+                },
+                components: {
+                    'component-test-2': {
+                        template: '<span>{{model.msg}}</span>'
+                    }
+                }
+            })
+            assert.strictEqual(t.$el.querySelector('span').textContent, '123')
         })
 
     })