test(compiler): test for DirectiveTransform returning needRuntime: Symbol
This commit is contained in:
parent
d376439167
commit
e6d0d08a43
@ -5,7 +5,8 @@ import {
|
|||||||
MERGE_PROPS,
|
MERGE_PROPS,
|
||||||
RESOLVE_DIRECTIVE,
|
RESOLVE_DIRECTIVE,
|
||||||
APPLY_DIRECTIVES,
|
APPLY_DIRECTIVES,
|
||||||
TO_HANDLERS
|
TO_HANDLERS,
|
||||||
|
helperNameMap
|
||||||
} from '../../src/runtimeHelpers'
|
} from '../../src/runtimeHelpers'
|
||||||
import {
|
import {
|
||||||
CallExpression,
|
CallExpression,
|
||||||
@ -349,6 +350,29 @@ describe('compiler: element transform', () => {
|
|||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('directiveTransform with needRuntime: Symbol', () => {
|
||||||
|
const { root, node } = parseWithElementTransform(
|
||||||
|
`<div v-foo:bar="hello" />`,
|
||||||
|
{
|
||||||
|
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', () => {
|
test('runtime directives', () => {
|
||||||
const { root, node } = parseWithElementTransform(
|
const { root, node } = parseWithElementTransform(
|
||||||
`<div v-foo v-bar="x" v-baz:[arg].mod.mad="y" />`
|
`<div v-foo v-bar="x" v-baz:[arg].mod.mad="y" />`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user