2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-18 19:20:33 +03:00

feat: add option for prepending (no)script to body (#410)

* feat: add option for prepending (no)script to body

* test: use browser getUrl

* refactor: use pbody insteadn of pody

* test: add prepend/append body generator test

* test: add prepend body updater test

* chore: remove typo
This commit is contained in:
Pim
2019-07-17 22:26:33 +02:00
committed by GitHub
parent f90cd41e52
commit 05163a77a8
11 changed files with 150 additions and 62 deletions
+7 -2
View File
@@ -114,10 +114,12 @@ const metaInfoData = {
add: {
data: [
{ src: 'src', async: false, defer: true, [defaultOptions.tagIDKeyName]: 'content' },
{ src: 'src-prepend', async: true, defer: false, pbody: true },
{ src: 'src', async: false, defer: true, body: true }
],
expect: [
'<script data-vue-meta="test" src="src" defer data-vmid="content"></script>',
'<script data-vue-meta="test" src="src-prepend" async data-pbody="true"></script>',
'<script data-vue-meta="test" src="src" defer data-body="true"></script>'
],
test (side, defaultTest) {
@@ -130,14 +132,17 @@ const metaInfoData = {
expect(tags.addedTags.script[0].parentNode.tagName).toBe('HEAD')
expect(tags.addedTags.script[1].parentNode.tagName).toBe('BODY')
expect(tags.addedTags.script[2].parentNode.tagName).toBe('BODY')
} else {
// ssr doesnt generate data-body tags
const bodyScript = this.expect[1]
const bodyPrepended = this.expect[1]
const bodyAppended = this.expect[2]
this.expect = [this.expect[0]]
const tags = defaultTest()
expect(tags.text()).not.toContain(bodyScript)
expect(tags.text()).not.toContain(bodyPrepended)
expect(tags.text()).not.toContain(bodyAppended)
}
}
}