]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: split ssr transition group tests
authorEvan You <yyx990803@gmail.com>
Wed, 18 May 2022 01:31:31 +0000 (09:31 +0800)
committerEvan You <yyx990803@gmail.com>
Wed, 18 May 2022 01:31:31 +0000 (09:31 +0800)
packages/compiler-ssr/__tests__/ssrComponent.spec.ts
packages/compiler-ssr/__tests__/ssrTransitionGroup.spec.ts [new file with mode: 0644]

index 2f279c090d20e75fbe233c543ea6df5f18b5b43e..24b926f83bc862861cb7b45fc63bfa4cf3b0c035 100644 (file)
@@ -367,94 +367,6 @@ describe('ssr: components', () => {
         `)
       })
     })
-
-    // transition-group should flatten and concat its children fragments into
-    // a single one
-    describe('transition-group', () => {
-      test('basic', () => {
-        expect(
-          compile(
-            `<transition-group><div v-for="i in list"/></transition-group>`
-          ).code
-        ).toMatchInlineSnapshot(`
-          "const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
-
-          return function ssrRender(_ctx, _push, _parent, _attrs) {
-            _push(\`<!--[-->\`)
-            _ssrRenderList(_ctx.list, (i) => {
-              _push(\`<div></div>\`)
-            })
-            _push(\`<!--]-->\`)
-          }"
-        `)
-      })
-
-      test('with static tag', () => {
-        expect(
-          compile(
-            `<transition-group tag="ul"><div v-for="i in list"/></transition-group>`
-          ).code
-        ).toMatchInlineSnapshot(`
-          "const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
-
-          return function ssrRender(_ctx, _push, _parent, _attrs) {
-            _push(\`<ul>\`)
-            _ssrRenderList(_ctx.list, (i) => {
-              _push(\`<div></div>\`)
-            })
-            _push(\`</ul>\`)
-          }"
-        `)
-      })
-
-      test('with dynamic tag', () => {
-        expect(
-          compile(
-            `<transition-group :tag="someTag"><div v-for="i in list"/></transition-group>`
-          ).code
-        ).toMatchInlineSnapshot(`
-          "const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
-
-          return function ssrRender(_ctx, _push, _parent, _attrs) {
-            _push(\`<\${_ctx.someTag}>\`)
-            _ssrRenderList(_ctx.list, (i) => {
-              _push(\`<div></div>\`)
-            })
-            _push(\`</\${_ctx.someTag}>\`)
-          }"
-        `)
-      })
-
-      test('with multi fragments children', () => {
-        expect(
-          compile(
-            `<transition-group>
-              <div v-for="i in 10"/>
-              <div v-for="i in 10"/>
-              <template v-if="ok"><div>ok</div></template>
-            </transition-group>`
-          ).code
-        ).toMatchInlineSnapshot(`
-          "const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
-
-          return function ssrRender(_ctx, _push, _parent, _attrs) {
-            _push(\`<!--[-->\`)
-            _ssrRenderList(10, (i) => {
-              _push(\`<div></div>\`)
-            })
-            _ssrRenderList(10, (i) => {
-              _push(\`<div></div>\`)
-            })
-            if (_ctx.ok) {
-              _push(\`<div>ok</div>\`)
-            } else {
-              _push(\`<!---->\`)
-            }
-            _push(\`<!--]-->\`)
-          }"
-        `)
-      })
-    })
   })
 
   describe('custom directive', () => {
diff --git a/packages/compiler-ssr/__tests__/ssrTransitionGroup.spec.ts b/packages/compiler-ssr/__tests__/ssrTransitionGroup.spec.ts
new file mode 100644 (file)
index 0000000..aee771f
--- /dev/null
@@ -0,0 +1,88 @@
+import { compile } from '../src'
+
+// transition-group should flatten and concat its children fragments into
+// a single one
+describe('transition-group', () => {
+  test('basic', () => {
+    expect(
+      compile(`<transition-group><div v-for="i in list"/></transition-group>`)
+        .code
+    ).toMatchInlineSnapshot(`
+      "const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
+
+      return function ssrRender(_ctx, _push, _parent, _attrs) {
+        _push(\`<!--[-->\`)
+        _ssrRenderList(_ctx.list, (i) => {
+          _push(\`<div></div>\`)
+        })
+        _push(\`<!--]-->\`)
+      }"
+    `)
+  })
+
+  test('with static tag', () => {
+    expect(
+      compile(
+        `<transition-group tag="ul"><div v-for="i in list"/></transition-group>`
+      ).code
+    ).toMatchInlineSnapshot(`
+      "const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
+
+      return function ssrRender(_ctx, _push, _parent, _attrs) {
+        _push(\`<ul>\`)
+        _ssrRenderList(_ctx.list, (i) => {
+          _push(\`<div></div>\`)
+        })
+        _push(\`</ul>\`)
+      }"
+    `)
+  })
+
+  test('with dynamic tag', () => {
+    expect(
+      compile(
+        `<transition-group :tag="someTag"><div v-for="i in list"/></transition-group>`
+      ).code
+    ).toMatchInlineSnapshot(`
+      "const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
+
+      return function ssrRender(_ctx, _push, _parent, _attrs) {
+        _push(\`<\${_ctx.someTag}>\`)
+        _ssrRenderList(_ctx.list, (i) => {
+          _push(\`<div></div>\`)
+        })
+        _push(\`</\${_ctx.someTag}>\`)
+      }"
+    `)
+  })
+
+  test('with multi fragments children', () => {
+    expect(
+      compile(
+        `<transition-group>
+              <div v-for="i in 10"/>
+              <div v-for="i in 10"/>
+              <template v-if="ok"><div>ok</div></template>
+            </transition-group>`
+      ).code
+    ).toMatchInlineSnapshot(`
+      "const { ssrRenderList: _ssrRenderList } = require(\\"vue/server-renderer\\")
+
+      return function ssrRender(_ctx, _push, _parent, _attrs) {
+        _push(\`<!--[-->\`)
+        _ssrRenderList(10, (i) => {
+          _push(\`<div></div>\`)
+        })
+        _ssrRenderList(10, (i) => {
+          _push(\`<div></div>\`)
+        })
+        if (_ctx.ok) {
+          _push(\`<div>ok</div>\`)
+        } else {
+          _push(\`<!---->\`)
+        }
+        _push(\`<!--]-->\`)
+      }"
+    `)
+  })
+})