import { assert } from './testUtils' describe('compiler: scope', () => { test('v-for', () => { assert( `{{item.title}}`, `{{item.a}}`, `(_ctx, _cache) => { return { a: _f(_ctx.items, (item, k0, i0) => { return { a: _t(item.title), b: item.id, c: item.isRed ? 1 : 0, d: _o($event => _ctx.onClick(item)) }; }), b: _o(_ctx.longpress) } }` ) }) test('v-for + v-for', () => { assert( `{{item.title}}{{handle(foo)}}{{item.id}}{{item1.title}}`, `{{item.a}}{{b}}{{item.c}}{{item1.a}}`, `(_ctx, _cache) => { return { a: _f(_ctx.items, (item, k0, i0) => { return { a: _t(item.title), b: _f(item.list, (item1, k1, i1) => { return { a: _t(item1.title), b: item1.id, c: _o($event => _ctx.longpress(item1)) }; }), c: _t(item.id), d: _o($event => _ctx.onClick(item)), e: item.id }; }), b: _t(_ctx.handle(_ctx.foo)) } }` ) assert( ``, ``, `(_ctx, _cache) => { return { a: _f(_ctx.items, (item, k0, i0) => { return { a: item.id }; }), b: _f(_ctx.item1, (item1, k1, i1) => { return { a: item1.title }; }) } }` ) assert( ``, ``, `(_ctx, _cache) => { return { a: _f(_ctx.weeks, (item, weekIndex, i0) => { return { a: _f(item, (weeks, weeksIndex, i1) => { return { a: weeksIndex, b: weeks.id }; }), b: weekIndex, c: item.id }; }) } }` ) }) test('v-for + v-if', () => { assert( ``, ``, `(_ctx, _cache) => { return { a: _f(_ctx.items, (item, k0, i0) => { return true ? { a: _ctx.id } : {}; }) } }` ) }) test('v-if', () => { assert( `{{ok}}{{ok1}}{{ok2}}{{ok3}}`, `{{b}}{{d}}{{f}}{{g}}`, `(_ctx, _cache) => { return _e({ a: _ctx.ok }, _ctx.ok ? { b: _t(_ctx.ok) } : _ctx.ok1 ? { d: _t(_ctx.ok1) } : _ctx.ok2 ? { f: _t(_ctx.ok2) } : { g: _t(_ctx.ok3) }, { c: _ctx.ok1, e: _ctx.ok2 }) }` ) }) test('v-if + v-for', () => { assert( ``, ``, `(_ctx, _cache) => { return _e({ a: _ctx.ok }, _ctx.ok ? { b: _f(_ctx.items, (item, k0, i0) => { return { a: item.id, b: item.title }; }), c: _ctx.foo, d: _o(_ctx.onClick) } : _ctx.ok1 ? { f: _f(_ctx.items, (item, k0, i0) => { return { a: item.id, b: item.title }; }), g: _ctx.foo, h: _o(_ctx.onClick) } : { i: _f(_ctx.items, (item, k0, i0) => { return { a: item.id, b: item.title }; }), j: _ctx.foo, k: _o(_ctx.onClick) }, { e: _ctx.ok1 }) }` ) }) })