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

More reliable strategy for getting deepmost component + addition of refresh() method + example & documentation on asynchronous updates

This commit is contained in:
Declan de Wet
2016-11-09 07:26:38 +02:00
parent fa290273df
commit 076832cbd6
18 changed files with 268 additions and 45 deletions
+8 -8
View File
@@ -9,14 +9,14 @@ describe('getComponentOption', () => {
it('returns an empty object when no matching options are found', () => {
component = new Vue()
const fetchedOption = getComponentOption({ component, option: 'noop' })
expect(fetchedOption).to.eql({})
const { mergedOption } = getComponentOption({ component, option: 'noop' })
expect(mergedOption).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')
const { mergedOption } = getComponentOption({ component, option: 'someOption' })
expect(mergedOption).to.eql('foo')
})
it('fetches deeply nested component options and merges them', () => {
@@ -28,8 +28,8 @@ describe('getComponentOption', () => {
el: container
})
const fetchedOption = getComponentOption({ component, option: 'foo', deep: true })
expect(fetchedOption).to.eql({ bar: 'baz', fizz: 'buzz' })
const { mergedOption } = getComponentOption({ component, option: 'foo', deep: true })
expect(mergedOption).to.eql({ bar: 'baz', fizz: 'buzz' })
})
it('allows for a custom array merge strategy', () => {
@@ -48,7 +48,7 @@ describe('getComponentOption', () => {
el: container
})
const fetchedOption = getComponentOption({
const { mergedOption } = getComponentOption({
component,
option: 'foo',
deep: true,
@@ -57,7 +57,7 @@ describe('getComponentOption', () => {
}
})
expect(fetchedOption).to.eql([
expect(mergedOption).to.eql([
{ name: 'flower', content: 'tulip' },
{ name: 'flower', content: 'rose' }
])