Skip to content

Commit 1035c6b

Browse files
committed
chore: split ssr transition group tests
1 parent ee4186e commit 1035c6b

File tree

2 files changed

+88
-88
lines changed

2 files changed

+88
-88
lines changed

packages/compiler-ssr/__tests__/ssrComponent.spec.ts

-88
Original file line numberDiff line numberDiff line change
@@ -367,94 +367,6 @@ describe('ssr: components', () => {
367367
`)
368368
})
369369
})
370-
371-
// transition-group should flatten and concat its children fragments into
372-
// a single one
373-
describe('transition-group', () => {
374-
test('basic', () => {
375-
expect(
376-
compile(
377-
`<transition-group><div v-for="i in list"/></transition-group>`
378-
).code
379-
).toMatchInlineSnapshot(`
380-
"const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
381-
382-
return function ssrRender(_ctx, _push, _parent, _attrs) {
383-
_push(\`<!--[-->\`)
384-
_ssrRenderList(_ctx.list, (i) => {
385-
_push(\`<div></div>\`)
386-
})
387-
_push(\`<!--]-->\`)
388-
}"
389-
`)
390-
})
391-
392-
test('with static tag', () => {
393-
expect(
394-
compile(
395-
`<transition-group tag="ul"><div v-for="i in list"/></transition-group>`
396-
).code
397-
).toMatchInlineSnapshot(`
398-
"const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
399-
400-
return function ssrRender(_ctx, _push, _parent, _attrs) {
401-
_push(\`<ul>\`)
402-
_ssrRenderList(_ctx.list, (i) => {
403-
_push(\`<div></div>\`)
404-
})
405-
_push(\`</ul>\`)
406-
}"
407-
`)
408-
})
409-
410-
test('with dynamic tag', () => {
411-
expect(
412-
compile(
413-
`<transition-group :tag="someTag"><div v-for="i in list"/></transition-group>`
414-
).code
415-
).toMatchInlineSnapshot(`
416-
"const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
417-
418-
return function ssrRender(_ctx, _push, _parent, _attrs) {
419-
_push(\`<\${_ctx.someTag}>\`)
420-
_ssrRenderList(_ctx.list, (i) => {
421-
_push(\`<div></div>\`)
422-
})
423-
_push(\`</\${_ctx.someTag}>\`)
424-
}"
425-
`)
426-
})
427-
428-
test('with multi fragments children', () => {
429-
expect(
430-
compile(
431-
`<transition-group>
432-
<div v-for="i in 10"/>
433-
<div v-for="i in 10"/>
434-
<template v-if="ok"><div>ok</div></template>
435-
</transition-group>`
436-
).code
437-
).toMatchInlineSnapshot(`
438-
"const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
439-
440-
return function ssrRender(_ctx, _push, _parent, _attrs) {
441-
_push(\`<!--[-->\`)
442-
_ssrRenderList(10, (i) => {
443-
_push(\`<div></div>\`)
444-
})
445-
_ssrRenderList(10, (i) => {
446-
_push(\`<div></div>\`)
447-
})
448-
if (_ctx.ok) {
449-
_push(\`<div>ok</div>\`)
450-
} else {
451-
_push(\`<!---->\`)
452-
}
453-
_push(\`<!--]-->\`)
454-
}"
455-
`)
456-
})
457-
})
458370
})
459371

460372
describe('custom directive', () => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import { compile } from '../src'
2+
3+
// transition-group should flatten and concat its children fragments into
4+
// a single one
5+
describe('transition-group', () => {
6+
test('basic', () => {
7+
expect(
8+
compile(`<transition-group><div v-for="i in list"/></transition-group>`)
9+
.code
10+
).toMatchInlineSnapshot(`
11+
"const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
12+
13+
return function ssrRender(_ctx, _push, _parent, _attrs) {
14+
_push(\`<!--[-->\`)
15+
_ssrRenderList(_ctx.list, (i) => {
16+
_push(\`<div></div>\`)
17+
})
18+
_push(\`<!--]-->\`)
19+
}"
20+
`)
21+
})
22+
23+
test('with static tag', () => {
24+
expect(
25+
compile(
26+
`<transition-group tag="ul"><div v-for="i in list"/></transition-group>`
27+
).code
28+
).toMatchInlineSnapshot(`
29+
"const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
30+
31+
return function ssrRender(_ctx, _push, _parent, _attrs) {
32+
_push(\`<ul>\`)
33+
_ssrRenderList(_ctx.list, (i) => {
34+
_push(\`<div></div>\`)
35+
})
36+
_push(\`</ul>\`)
37+
}"
38+
`)
39+
})
40+
41+
test('with dynamic tag', () => {
42+
expect(
43+
compile(
44+
`<transition-group :tag="someTag"><div v-for="i in list"/></transition-group>`
45+
).code
46+
).toMatchInlineSnapshot(`
47+
"const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
48+
49+
return function ssrRender(_ctx, _push, _parent, _attrs) {
50+
_push(\`<\${_ctx.someTag}>\`)
51+
_ssrRenderList(_ctx.list, (i) => {
52+
_push(\`<div></div>\`)
53+
})
54+
_push(\`</\${_ctx.someTag}>\`)
55+
}"
56+
`)
57+
})
58+
59+
test('with multi fragments children', () => {
60+
expect(
61+
compile(
62+
`<transition-group>
63+
<div v-for="i in 10"/>
64+
<div v-for="i in 10"/>
65+
<template v-if="ok"><div>ok</div></template>
66+
</transition-group>`
67+
).code
68+
).toMatchInlineSnapshot(`
69+
"const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
70+
71+
return function ssrRender(_ctx, _push, _parent, _attrs) {
72+
_push(\`<!--[-->\`)
73+
_ssrRenderList(10, (i) => {
74+
_push(\`<div></div>\`)
75+
})
76+
_ssrRenderList(10, (i) => {
77+
_push(\`<div></div>\`)
78+
})
79+
if (_ctx.ok) {
80+
_push(\`<div>ok</div>\`)
81+
} else {
82+
_push(\`<!---->\`)
83+
}
84+
_push(\`<!--]-->\`)
85+
}"
86+
`)
87+
})
88+
})

0 commit comments

Comments
 (0)