mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-22 10:00:33 +03:00
committed by
Alexander Lichter
parent
23c3380c90
commit
7615f4120c
@@ -36,7 +36,6 @@ export default function getComponentOption(options = {}, result = {}) {
|
|||||||
|
|
||||||
// ignore data if its not an object, then we keep our previous result
|
// ignore data if its not an object, then we keep our previous result
|
||||||
if (!isObject(data)) {
|
if (!isObject(data)) {
|
||||||
console.log(data)
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,21 +13,23 @@ describe('getComponentOption', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('fetches the given option from the given component', () => {
|
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' })
|
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', () => {
|
it('calls a function option, injecting the component as context', () => {
|
||||||
const component = new Vue({
|
const component = new Vue({
|
||||||
name: 'Foobar',
|
name: 'Foobar',
|
||||||
someFunc() {
|
someFunc() {
|
||||||
return this.$options.name
|
return { opt: this.$options.name }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const mergedOption = getComponentOption({ component, keyName: 'someFunc' })
|
const mergedOption = getComponentOption({ component, keyName: 'someFunc' })
|
||||||
// TODO: Should this be foobar or Foobar
|
// 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', () => {
|
it('fetches deeply nested component options and merges them', () => {
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ describe('getMetaInfo', () => {
|
|||||||
{
|
{
|
||||||
vmid: 'a',
|
vmid: 'a',
|
||||||
property: 'a',
|
property: 'a',
|
||||||
content: 'b'
|
content: 'a'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
base: [],
|
base: [],
|
||||||
@@ -592,4 +592,29 @@ describe('getMetaInfo', () => {
|
|||||||
__dangerouslyDisableSanitizersByTagID: {}
|
__dangerouslyDisableSanitizersByTagID: {}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('no errors when metaInfo returns nothing', () => {
|
||||||
|
const component = new Vue({
|
||||||
|
metaInfo() {},
|
||||||
|
el: document.createElement('div'),
|
||||||
|
render: h => h('div', null, [])
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(getMetaInfo(component)).toEqual({
|
||||||
|
title: '',
|
||||||
|
titleChunk: '',
|
||||||
|
titleTemplate: '%s',
|
||||||
|
htmlAttrs: {},
|
||||||
|
headAttrs: {},
|
||||||
|
bodyAttrs: {},
|
||||||
|
meta: [],
|
||||||
|
base: [],
|
||||||
|
link: [],
|
||||||
|
style: [],
|
||||||
|
script: [],
|
||||||
|
noscript: [],
|
||||||
|
__dangerouslyDisableSanitizers: [],
|
||||||
|
__dangerouslyDisableSanitizersByTagID: {}
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user