From: Evan You Date: Thu, 10 Oct 2019 22:05:43 +0000 (-0400) Subject: test(compiler): test for DirectiveTransform returning needRuntime: Symbol X-Git-Tag: v3.0.0-alpha.0~505 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e6d0d08a435a03574c49865bdc527d717e8b55d2;p=thirdparty%2Fvuejs%2Fcore.git test(compiler): test for DirectiveTransform returning needRuntime: Symbol --- diff --git a/packages/compiler-core/__tests__/transforms/transformElement.spec.ts b/packages/compiler-core/__tests__/transforms/transformElement.spec.ts index 072d34950f..ae44be6847 100644 --- a/packages/compiler-core/__tests__/transforms/transformElement.spec.ts +++ b/packages/compiler-core/__tests__/transforms/transformElement.spec.ts @@ -5,7 +5,8 @@ import { MERGE_PROPS, RESOLVE_DIRECTIVE, APPLY_DIRECTIVES, - TO_HANDLERS + TO_HANDLERS, + helperNameMap } from '../../src/runtimeHelpers' import { CallExpression, @@ -349,6 +350,29 @@ describe('compiler: element transform', () => { ]) }) + test('directiveTransform with needRuntime: Symbol', () => { + const { root, node } = parseWithElementTransform( + `
`, + { + directiveTransforms: { + foo() { + return { + props: [], + needRuntime: CREATE_VNODE + } + } + } + } + ) + + expect(root.helpers).toContain(CREATE_VNODE) + expect(root.helpers).not.toContain(RESOLVE_DIRECTIVE) + expect(root.directives.length).toBe(0) + expect((node as any).arguments[1].elements[0].elements[0]).toBe( + `_${helperNameMap[CREATE_VNODE]}` + ) + }) + test('runtime directives', () => { const { root, node } = parseWithElementTransform( `
`