Преглед изворни кода

test: fix tests w/ nested CompoundExpressions

Evan You пре 6 година
родитељ
комит
8f9e85afb1

+ 1 - 1
packages/compiler-core/__tests__/__snapshots__/codegen.spec.ts.snap

@@ -99,7 +99,7 @@ exports[`compiler: codegen compound expression 1`] = `
 "
 return function render() {
   with (this) {
-    return _ctx.foo + _toDisplayString(bar)
+    return _ctx.foo + _toDisplayString(bar) + nested
   }
 }"
 `;

+ 4 - 2
packages/compiler-core/__tests__/codegen.spec.ts

@@ -207,12 +207,14 @@ describe('compiler: codegen', () => {
             type: NodeTypes.INTERPOLATION,
             loc: locStub,
             content: createSimpleExpression(`bar`, false, locStub)
-          }
+          },
+          // nested compound
+          createCompoundExpression([` + `, `nested`])
         ])
       })
     )
     expect(code).toMatch(
-      `return _ctx.foo + _${helperNameMap[TO_DISPLAY_STRING]}(bar)`
+      `return _ctx.foo + _${helperNameMap[TO_DISPLAY_STRING]}(bar) + nested`
     )
     expect(code).toMatchSnapshot()
   })

+ 12 - 8
packages/compiler-core/__tests__/transforms/vModel.spec.ts

@@ -191,15 +191,19 @@ describe('compiler: transform v-model', () => {
         children: [
           '$event => (',
           {
-            content: '_ctx.model',
-            isStatic: false
-          },
-          '[',
-          {
-            content: '_ctx.index',
-            isStatic: false
+            children: [
+              {
+                content: '_ctx.model',
+                isStatic: false
+              },
+              '[',
+              {
+                content: '_ctx.index',
+                isStatic: false
+              },
+              ']'
+            ]
           },
-          ']',
           ' = $event)'
         ]
       }

+ 26 - 13
packages/compiler-core/__tests__/transforms/vOn.spec.ts

@@ -168,11 +168,16 @@ describe('compiler: transform v-on', () => {
         type: NodeTypes.COMPOUND_EXPRESSION,
         children: [
           `$event => (`,
-          { content: `_ctx.foo` },
-          `(`,
-          // should NOT prefix $event
-          { content: `$event` },
-          `)`,
+          {
+            type: NodeTypes.COMPOUND_EXPRESSION,
+            children: [
+              { content: `_ctx.foo` },
+              `(`,
+              // should NOT prefix $event
+              { content: `$event` },
+              `)`
+            ]
+          },
           `)`
         ]
       }
@@ -191,13 +196,17 @@ describe('compiler: transform v-on', () => {
         type: NodeTypes.COMPOUND_EXPRESSION,
         children: [
           `$event => {`,
-          { content: `_ctx.foo` },
-          `(`,
-          // should NOT prefix $event
-          { content: `$event` },
-          `);`,
-          { content: `_ctx.bar` },
-          `()`,
+          {
+            children: [
+              { content: `_ctx.foo` },
+              `(`,
+              // should NOT prefix $event
+              { content: `$event` },
+              `);`,
+              { content: `_ctx.bar` },
+              `()`
+            ]
+          },
           `}`
         ]
       }
@@ -363,7 +372,11 @@ describe('compiler: transform v-on', () => {
         index: 1,
         value: {
           type: NodeTypes.COMPOUND_EXPRESSION,
-          children: [`$event => (`, { content: `_ctx.foo` }, `++`, `)`]
+          children: [
+            `$event => (`,
+            { children: [{ content: `_ctx.foo` }, `++`] },
+            `)`
+          ]
         }
       })
     })