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

Add test to check this binding during function call

This commit is contained in:
Sean
2017-09-08 12:58:59 -07:00
parent c3cc4bdae4
commit 47fb79e0ee
+38
View File
@@ -129,4 +129,42 @@ describe('getMetaInfo', () => {
__dangerouslyDisableSanitizers: []
})
})
it('has the proper `this` binding when using function titleTemplates', () => {
const titleTemplate = function (chunk) {
return `${chunk} ${this.helloWorldText}`
}
component = new Vue({
metaInfo: {
title: 'Hello',
titleTemplate: titleTemplate,
meta: [
{ charset: 'utf-8' }
]
},
data () {
return {
helloWorldText: 'Function World'
}
}
})
expect(getMetaInfo(component)).to.eql({
title: 'Hello Function World',
titleChunk: 'Hello',
titleTemplate: titleTemplate,
htmlAttrs: {},
headAttrs: {},
bodyAttrs: {},
meta: [
{ charset: 'utf-8' }
],
base: [],
link: [],
style: [],
script: [],
noscript: [],
__dangerouslyDisableSanitizers: []
})
})
})