]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test(compiler-core): include test case for expression prefixing in assignments
authorEvan You <yyx990803@gmail.com>
Sun, 22 Aug 2021 16:33:00 +0000 (12:33 -0400)
committerEvan You <yyx990803@gmail.com>
Sun, 22 Aug 2021 16:33:00 +0000 (12:33 -0400)
packages/compiler-core/__tests__/transforms/transformExpressions.spec.ts

index 2466fffe8afcfa00bb8997116a6a42223712bdb3..4db7aa619037e3cf3a716e76d3d4194be7740842 100644 (file)
@@ -402,6 +402,33 @@ describe('compiler: expression transform', () => {
     )
   })
 
+  test('should prefix in assignment', () => {
+    const node = parseWithExpressionTransform(
+      `{{ x = 1 }}`
+    ) as InterpolationNode
+    expect(node.content).toMatchObject({
+      type: NodeTypes.COMPOUND_EXPRESSION,
+      children: [{ content: `_ctx.x` }, ` = 1`]
+    })
+  })
+
+  test('should prefix in assignment pattern', () => {
+    const node = parseWithExpressionTransform(
+      `{{ { x, y: [z] } = obj }}`
+    ) as InterpolationNode
+    expect(node.content).toMatchObject({
+      type: NodeTypes.COMPOUND_EXPRESSION,
+      children: [
+        `{ x: `,
+        { content: `_ctx.x` },
+        `, y: [`,
+        { content: `_ctx.z` },
+        `] } = `,
+        { content: `_ctx.obj` }
+      ]
+    })
+  })
+
   describe('ES Proposals support', () => {
     test('bigInt', () => {
       const node = parseWithExpressionTransform(