import { assert } from './testUtils'
describe('compiler: transform scoped slots', () => {
test('basic', () => {
assert(
``,
``,
`(_ctx, _cache) => {
return { a: _r("d", { item: _ctx.item, index: _ctx.index }) }
}`
)
})
test('named slots', () => {
assert(
``,
``,
`(_ctx, _cache) => {
return { a: _r("header", { item: _ctx.item, index: _ctx.index }) }
}`
)
})
test('named slots + v-if', () => {
assert(
``,
``,
`(_ctx, _cache) => {
return _e({ a: _ctx.ok }, _ctx.ok ? { b: _r("header", { item: _ctx.item, index: _ctx.index }) } : {})
}`
)
})
test('v-for + v-for + scoped slots', () => {
assert(
``,
``,
`(_ctx, _cache) => {
return { a: _f(4, (item, index, i0) => { return { a: _f(4, (item, index, i1) => { return { a: "d-" + i0 + '-' + i1, b: _r("d", { text: 1 }, i0 + '-' + i1) }; }), b: index }; }) }
}`
)
})
test('v-for + v-for + v-for + scoped slots', () => {
assert(
``,
``,
`(_ctx, _cache) => {
return { a: _f(4, (item, index, i0) => { return { a: _f(4, (item, index, i1) => { return { a: _f(4, (item, index, i2) => { return { a: "d-" + i0 + '-' + i1 + '-' + i2, b: _r("d", { text: 1 }, i0 + '-' + i1 + '-' + i2) }; }) }; }), b: index }; }) }
}`
)
})
test('scoped + v-for + component', () => {
assert(
`
{{ item.title }}
`,
`{{item.a}}`,
`(_ctx, _cache) => {
return { a: _w((slotProps, s0, i0) => { return { a: _f(_ctx.dataList, (item, key, i1) => { return { a: _t(item.title), b: '2a9ec0b0-1' + '-' + i0 + '-' + i1 + ',' + '2a9ec0b0-0', c: key }; }), b: i0, c: s0 }; }, { name: 'd', path: 'a', vueId: '2a9ec0b0-0' }), b: _p({ dataList: _ctx.dataList }) }
}`
)
})
})