Skip to content

Commit a32650a

Browse files
committed
test(compiler-vapor): add test for v-if with v-once
1 parent 06d3691 commit a32650a

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

packages/compiler-vapor/__tests__/transforms/__snapshots__/vIf.spec.ts.snap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,18 @@ export function render(_ctx) {
293293
return [n0, n6]
294294
}"
295295
`;
296+
297+
exports[`compiler: v-if > v-if with v-once 1`] = `
298+
"import { txt as _txt, toDisplayString as _toDisplayString, setText as _setText, createIf as _createIf, template as _template } from 'vue';
299+
const t0 = _template("<div> </div>", true)
300+
301+
export function render(_ctx) {
302+
const n0 = _createIf(() => (_ctx.ok), () => {
303+
const n2 = t0()
304+
const x2 = _txt(n2)
305+
_setText(x2, _toDisplayString(_ctx.msg))
306+
return n2
307+
}, null, true)
308+
return n0
309+
}"
310+
`;

packages/compiler-vapor/__tests__/transforms/vIf.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,14 @@ describe('compiler: v-if', () => {
204204
expect(ir.block.returns).toEqual([0, 3])
205205
})
206206

207-
test.todo('v-if with v-once')
207+
test('v-if with v-once', () => {
208+
const { code, ir, helpers } = compileWithVIf(
209+
`<div v-if="ok" v-once>{{ msg }}</div>`,
210+
)
211+
expect(code).matchSnapshot()
212+
expect(helpers).contains('createIf')
213+
expect([...ir.template.keys()]).toEqual(['<div> </div>'])
214+
})
208215

209216
test('component v-if', () => {
210217
const { code, ir, helpers } = compileWithVIf(

0 commit comments

Comments
 (0)