diff --git a/packages/compiler-sfc/test/prefixIdentifiers.spec.ts b/packages/compiler-sfc/test/prefixIdentifiers.spec.ts index cfc60c88989..0a1ee2351b2 100644 --- a/packages/compiler-sfc/test/prefixIdentifiers.spec.ts +++ b/packages/compiler-sfc/test/prefixIdentifiers.spec.ts @@ -1,6 +1,7 @@ import { prefixIdentifiers } from '../src/prefixIdentifiers' import { compile } from 'web/entry-compiler' import { format } from 'prettier' +import { BindingTypes } from '../src/types' it('should work', () => { const { render } = compile(`
@@ -53,3 +54,41 @@ it('should work', () => { " `) }) + +it('setup bindings', () => { + const { render } = compile(`
{{ count }}
`) + + const result = format( + prefixIdentifiers(render, `render`, false, false, undefined, { + count: BindingTypes.SETUP_REF + }), + { + semi: false, + parser: 'babel' + } + ) + + expect(result).toMatch(`_setup = _vm._setupProxy`) + expect(result).toMatch(`_setup.count++`) + expect(result).toMatch(`_vm._s(_setup.count)`) + + expect(result).toMatchInlineSnapshot(` + "function render() { + var _vm = this, + _c = _vm._self._c, + _setup = _vm._setupProxy + return _c( + \\"div\\", + { + on: { + click: function (\$event) { + _setup.count++ + }, + }, + }, + [_vm._v(_vm._s(_setup.count))] + ) + } + " + `) +})