test(compiler-ssr): v-for tests

This commit is contained in:
Evan You
2020-02-03 20:47:41 -05:00
parent 93c37b94f2
commit 8cf6b5731d
5 changed files with 172 additions and 12 deletions

View File

@@ -119,7 +119,23 @@ describe('ssr: v-if', () => {
})
test('<template v-if> (with v-for inside)', () => {
// TODO should not contain nested fragments
expect(
compile(`<template v-if="foo"><div v-for="i in list"/></template>`).code
).toMatchInlineSnapshot(`
"const { _renderList } = require(\\"@vue/server-renderer\\")
return function ssrRender(_ctx, _push, _parent) {
if (_ctx.foo) {
_push(\`<!---->\`)
_renderList(_ctx.list, (i) => {
_push(\`<div></div>\`)
})
_push(\`<!---->\`)
} else {
_push(\`<!---->\`)
}
}"
`)
})
test('<template v-if> + normal v-else', () => {