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

test: add missing test for sanitizeByTagId

fix: broken sanitizeByTagId implementation
This commit is contained in:
pimlie
2019-03-08 18:53:13 +01:00
committed by Alexander Lichter
parent da4bb27a4b
commit ce7eaf56d3
3 changed files with 58 additions and 15 deletions
+33
View File
@@ -34,4 +34,37 @@ describe('escaping', () => {
__dangerouslyDisableSanitizersByTagID: {}
})
})
test('special chars are escaped unless disabled by vmid', () => {
const component = new Vue({
metaInfo: {
title: 'Hello',
script: [
{ vmid: 'yescape', innerHTML: 'Hello & Goodbye' },
{ vmid: 'noscape', innerHTML: 'Hello & Goodbye' }
],
__dangerouslyDisableSanitizersByTagID: { noscape: ['innerHTML'] }
}
})
expect(getMetaInfo(component, [[/&/g, '&']])).toEqual({
title: 'Hello',
titleChunk: 'Hello',
titleTemplate: '%s',
htmlAttrs: {},
headAttrs: {},
bodyAttrs: {},
meta: [],
base: [],
link: [],
style: [],
script: [
{ innerHTML: 'Hello & Goodbye', vmid: 'yescape' },
{ innerHTML: 'Hello & Goodbye', vmid: 'noscape' }
],
noscript: [],
__dangerouslyDisableSanitizers: [],
__dangerouslyDisableSanitizersByTagID: { noscape: ['innerHTML'] }
})
})
})