Skip to content

Commit 309ea3d

Browse files
committed
unit test for v-component
1 parent 0d3248d commit 309ea3d

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

test/unit/specs/directives.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,41 @@ describe('UNIT: Directives', function () {
572572
describe('component', function () {
573573

574574
it('should work with no args', function () {
575-
assert.ok(false)
575+
var testId = 'component-test'
576+
mock(testId, '<div v-component="' + testId + '"></div>')
577+
var t = new Vue({
578+
el: '#' + testId,
579+
scope: {
580+
msg: '123'
581+
},
582+
components: {
583+
'component-test': {
584+
template: '<span>{{msg}}</span>'
585+
}
586+
}
587+
})
588+
assert.strictEqual(t.$el.querySelector('span').textContent, '123')
576589
})
577590

578591
it('should work with arg (passed-in model from parent)', function () {
579-
assert.ok(false)
592+
var testId = 'component-test-2'
593+
mock(testId, '<div v-component="' + testId + ':options.test"></div>')
594+
var t = new Vue({
595+
el: '#' + testId,
596+
scope: {
597+
options: {
598+
test: {
599+
msg: '123'
600+
}
601+
}
602+
},
603+
components: {
604+
'component-test-2': {
605+
template: '<span>{{model.msg}}</span>'
606+
}
607+
}
608+
})
609+
assert.strictEqual(t.$el.querySelector('span').textContent, '123')
580610
})
581611

582612
})

0 commit comments

Comments
 (0)