Skip to content

Commit 2f4ad14

Browse files
committed
test template v-if/v-for
1 parent ac0e168 commit 2f4ad14

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

test/ssr/ssr-string.spec.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ describe('SSR: renderToString', () => {
778778
expect(vm.a).toBe(func)
779779
})
780780

781-
it('should prevent xss in attribtues', () => {
781+
it('should prevent xss in attribtues', done => {
782782
renderVmWithOptions({
783783
data: {
784784
xss: '"><script>alert(1)</script>'
@@ -790,6 +790,39 @@ describe('SSR: renderToString', () => {
790790
`
791791
}, res => {
792792
expect(res).not.toContain(`<script>alert(1)</script>`)
793+
done()
794+
})
795+
})
796+
797+
it('template v-if', done => {
798+
renderVmWithOptions({
799+
template: `
800+
<div>
801+
<span>foo</span>
802+
<template v-if="true">
803+
<span>foo</span> bar <span>baz</span>
804+
</template>
805+
</div>
806+
`
807+
}, res => {
808+
expect(res).toContain(`<div data-server-rendered="true"><span>foo</span> <span>foo</span> bar <span>baz</span></div>`)
809+
done()
810+
})
811+
})
812+
813+
it('template v-for', done => {
814+
renderVmWithOptions({
815+
template: `
816+
<div>
817+
<span>foo</span>
818+
<template v-for="i in 2">
819+
<span>{{ i }}</span><span>bar</span>
820+
</template>
821+
</div>
822+
`
823+
}, res => {
824+
expect(res).toContain(`<div data-server-rendered="true"><span>foo</span> <span>1</span><span>bar</span><span>2</span><span>bar</span></div>`)
825+
done()
793826
})
794827
})
795828
})

0 commit comments

Comments
 (0)