2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-05-26 20:54:05 +03:00

improve tests for getComponentOption

This commit is contained in:
Declan de Wet
2016-11-05 07:33:13 +02:00
parent 6a1f1c280d
commit 8aec696ffa
2 changed files with 29 additions and 14 deletions
+21
View File
@@ -7,12 +7,33 @@ describe('getComponentOption', () => {
afterEach(() => component.$destroy())
it('returns an empty object when no matching options are found', () => {
component = new Vue()
const fetchedOption = getComponentOption({ component, option: 'noop' })
expect(fetchedOption).to.eql({})
})
it('fetches the given option from the given component', () => {
component = new Vue({ someOption: 'foo' })
const fetchedOption = getComponentOption({ component, option: 'someOption' })
expect(fetchedOption).to.eql('foo')
})
it('binds option method context to the component instance', () => {
component = new Vue({
data: {
age: 44
},
foo: {
bar () {
return this.age
}
}
})
const fetchedOption = getComponentOption({ component, option: 'foo' })
expect(fetchedOption.bar()).to.equal(44)
})
it('fetches deeply nested component options and merges them', () => {
Vue.component('merge-child', { template: '<div></div>', foo: { bar: 'baz' } })