Skip to content

Commit

Permalink
unit test for v-component
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 22, 2013
1 parent 0d3248d commit 309ea3d
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions test/unit/specs/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})

})
Expand Down

0 comments on commit 309ea3d

Please sign in to comment.