import { BindingTypes } from '@vue/compiler-core' import { assert } from './testUtils' describe('mp-alipay: transform ref', () => { test('without ref', () => { assert( ``, ``, `(_ctx, _cache) => { return {} }` ) assert( ``, ``, `(_ctx, _cache) => { return {} }` ) }) test('static ref', () => { assert( ``, ``, `import { resolveComponent as _resolveComponent } from "vue" const __BINDING_COMPONENTS__ = '{"custom":{"name":"_component_custom","type":"unknown"}}' if (!Array) {const _component_custom = _resolveComponent("custom");Math.max.call(null, _component_custom);} export function render(_ctx, _cache) { return {} }`, { inline: false, } ) assert( ``, ``, `import { resolveComponent as _resolveComponent, f as _f } from "vue" const __BINDING_COMPONENTS__ = '{"custom":{"name":"_component_custom","type":"unknown"}}' if (!Array) {const _component_custom = _resolveComponent("custom");Math.max.call(null, _component_custom);} export function render(_ctx, _cache) { return { a: _f(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-0' + '-' + i0 }; }) } }`, { inline: false, } ) }) test('static ref with inline', () => { assert( ``, ``, `(_ctx, _cache) => { return { a: () => ({ r: custom }) } }` ) assert( ``, ``, `(_ctx, _cache) => { return { a: _f(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-0' + '-' + i0 }; }), b: () => ({ r: custom, f: 1 }) } }` ) }) test('static ref with inline and setup-ref', () => { assert( ``, ``, `(_ctx, _cache) => { return { a: () => ({ r: custom, k: 'custom' }) } }`, { bindingMetadata: { custom: BindingTypes.SETUP_REF, }, } ) }) test('static ref with inline and setup-maybe-ref', () => { assert( ``, ``, `(_ctx, _cache) => { return { a: () => ({ r: custom, k: 'custom' }) } }`, { bindingMetadata: { custom: BindingTypes.SETUP_MAYBE_REF, }, } ) }) test('static ref with inline and setup-let', () => { assert( ``, ``, `(_ctx, _cache) => { return { a: () => ({ r: custom, k: 'custom' }) } }`, { bindingMetadata: { custom: BindingTypes.SETUP_LET, }, } ) }) test('dynamic ref', () => { assert( ``, ``, `import { resolveComponent as _resolveComponent } from "vue" const __BINDING_COMPONENTS__ = '{"custom":{"name":"_component_custom","type":"unknown"}}' if (!Array) {const _component_custom = _resolveComponent("custom");Math.max.call(null, _component_custom);} export function render(_ctx, _cache) { return { a: _ctx.custom } }`, { inline: false, } ) assert( ``, ``, `import { resolveComponent as _resolveComponent, f as _f } from "vue" const __BINDING_COMPONENTS__ = '{"custom":{"name":"_component_custom","type":"unknown"}}' if (!Array) {const _component_custom = _resolveComponent("custom");Math.max.call(null, _component_custom);} export function render(_ctx, _cache) { return { a: _f(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-0' + '-' + i0 }; }), b: _ctx.custom } }`, { inline: false, } ) }) })