Explorar el Código

test(compiler-core): add test for custom delimiter (#315)

大江东去 hace 6 años
padre
commit
bb9dca2047
Se han modificado 1 ficheros con 28 adiciones y 0 borrados
  1. 28 0
      packages/compiler-core/__tests__/parse.spec.ts

+ 28 - 0
packages/compiler-core/__tests__/parse.spec.ts

@@ -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', () => {