]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test(compiler-core): add test for custom delimiter (#315)
author大江东去 <6405352+dlxqlig@users.noreply.github.com>
Thu, 17 Oct 2019 19:04:52 +0000 (03:04 +0800)
committerEvan You <yyx990803@gmail.com>
Thu, 17 Oct 2019 19:04:52 +0000 (15:04 -0400)
packages/compiler-core/__tests__/parse.spec.ts

index 4237b5faf7b01ab19f554308025cc0b3808bdff8..81735aa16aa8ebbcce36a1a5f2e36aebbd05746d 100644 (file)
@@ -410,6 +410,34 @@ describe('compiler: parse', () => {
         }
       })
     })
+
+    test('custom delimiters', () => {
+      const ast = parse('<p>{msg}</p>', {
+        delimiters: ['{', '}']
+      })
+      const element = ast.children[0] as ElementNode
+      const interpolation = element.children[0] as InterpolationNode
+
+      expect(interpolation).toStrictEqual({
+        type: NodeTypes.INTERPOLATION,
+        content: {
+          type: NodeTypes.SIMPLE_EXPRESSION,
+          content: `msg`,
+          isStatic: false,
+          isConstant: false,
+          loc: {
+            start: { offset: 4, line: 1, column: 5 },
+            end: { offset: 7, line: 1, column: 8 },
+            source: 'msg'
+          }
+        },
+        loc: {
+          start: { offset: 3, line: 1, column: 4 },
+          end: { offset: 8, line: 1, column: 9 },
+          source: '{msg}'
+        }
+      })
+    })
   })
 
   describe('Comment', () => {