"
`;
+exports[`compile > expression parsing > v-for 1`] = `
+"import { createFor as _createFor, template as _template } from 'vue';
+const t0 = _template("<div></div>")
+
+export function render(_ctx) {
+ const n0 = _createFor(() => (_ctx.a.b), (_for_item0, _for_key0, _for_index0) => {
+ const n2 = t0()
+ return n2
+ })
+ return n0
+}"
+`;
+
+exports[`compile > expression parsing > v-on multi statements 1`] = `
+"import { createInvoker as _createInvoker, delegateEvents as _delegateEvents, template as _template } from 'vue';
+const t0 = _template("<div></div>", true)
+_delegateEvents("click")
+
+export function render(_ctx) {
+ const n0 = t0()
+ n0.$evtclick = _createInvoker(() => {_ctx.a++;_ctx.b++})
+ return n0
+}"
+`;
+
+exports[`compile > expression parsing > v-slot 1`] = `
+"import { resolveComponent as _resolveComponent, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, withVaporCtx as _withVaporCtx, createComponentWithFallback as _createComponentWithFallback, template as _template } from 'vue';
+const t0 = _template(" ")
+
+export function render(_ctx) {
+ const _component_Comp = _resolveComponent("Comp")
+ const n1 = _createComponentWithFallback(_component_Comp, null, {
+ "foo": _withVaporCtx((_slotProps0) => {
+ const n0 = t0()
+ _renderEffect(() => _setText(n0, _toDisplayString(_slotProps0["a"] + _slotProps0["b"])))
+ return n0
+ })
+ }, true)
+ return n1
+}"
+`;
+
exports[`compile > fragment 1`] = `
"import { template as _template } from 'vue';
const t0 = _template("<p></p>")
)
expect(code).toMatchSnapshot()
- // Waiting for TODO, There should be more here.
})
})
)
})
- // TODO: add more test for expression parsing (v-on, v-slot, v-for)
+ test('v-on multi statements', () => {
+ const code = compile(`<div @click="a++;b++" />`, {
+ prefixIdentifiers: true,
+ })
+ expect(code).matchSnapshot()
+ })
+
+ test('v-slot', () => {
+ const code = compile(`<Comp #foo="{ a, b }">{{ a + b }}</Comp>`, {
+ prefixIdentifiers: true,
+ })
+ expect(code).matchSnapshot()
+ })
+
+ test('v-for', () => {
+ const code = compile(`<div v-for="({ a, b }, key, index) of a.b" />`, {
+ prefixIdentifiers: true,
+ })
+ expect(code).matchSnapshot()
+ })
})
describe('custom directive', () => {