2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-05 23:32:23 +03:00

fix: ignore data when its not an object (fixes: #253, #279, #297)

This commit is contained in:
pimlie
2019-03-08 13:45:57 +01:00
committed by Alexander Lichter
parent 23c3380c90
commit 7615f4120c
3 changed files with 32 additions and 6 deletions
+6 -4
View File
@@ -13,21 +13,23 @@ describe('getComponentOption', () => {
})
it('fetches the given option from the given component', () => {
const component = new Vue({ someOption: 'foo' })
const component = new Vue({ someOption: { foo: 'bar' } })
const mergedOption = getComponentOption({ component, keyName: 'someOption' })
expect(mergedOption).toEqual('foo')
expect(mergedOption.foo).toBeDefined()
expect(mergedOption.foo).toEqual('bar')
})
it('calls a function option, injecting the component as context', () => {
const component = new Vue({
name: 'Foobar',
someFunc() {
return this.$options.name
return { opt: this.$options.name }
}
})
const mergedOption = getComponentOption({ component, keyName: 'someFunc' })
// TODO: Should this be foobar or Foobar
expect(mergedOption).toEqual('Foobar')
expect(mergedOption.opt).toBeDefined()
expect(mergedOption.opt).toEqual('Foobar')
})
it('fetches deeply nested component options and merges them', () => {