import { ElementNode } from '@vue/compiler-core' import { compile } from '../src' import { MPErrorCodes } from '../src/errors' import { CompilerOptions } from '../src/options' import { assert } from './testUtils' function parseWithVOn(template: string, options: CompilerOptions = {}) { const { ast } = compile(template, options) return { root: ast, node: ast.children[0] as ElementNode, } } describe('compiler(mp): transform v-on', () => { test('lazy element', () => { assert( ``, ``, `(_ctx, _cache) => { return {} }` ) assert( ``, ``, `(_ctx, _cache) => { return { a: _vOn(_ctx.ready) } }` ) }) test('should error if dynamic event', () => { const onError = jest.fn() parseWithVOn(`
`, { onError }) expect(onError.mock.calls[0][0]).toMatchObject({ code: MPErrorCodes.X_V_ON_DYNAMIC_EVENT, loc: { start: { line: 1, column: 6, }, end: { line: 1, column: 28, }, }, }) }) })