Skip to content

Commit f643f3a

Browse files
committed
test: add tests
1 parent 4885fea commit f643f3a

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

packages/compiler-dom/__tests__/transforms/__snapshots__/vModel.spec.ts.snap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ return function render(_ctx, _cache) {
4848
}"
4949
`;
5050

51+
exports[`compiler: transform v-model > input with v-bind shorthand type should use dynamic model 1`] = `
52+
"const _Vue = Vue
53+
54+
return function render(_ctx, _cache) {
55+
with (_ctx) {
56+
const { vModelDynamic: _vModelDynamic, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
57+
58+
return _withDirectives((_openBlock(), _createElementBlock("input", {
59+
"onUpdate:modelValue": $event => ((model) = $event)
60+
}, null, 8 /* PROPS */, ["onUpdate:modelValue"])), [
61+
[_vModelDynamic, model]
62+
])
63+
}
64+
}"
65+
`;
66+
5167
exports[`compiler: transform v-model > modifiers > .lazy 1`] = `
5268
"const _Vue = Vue
5369

packages/compiler-dom/__tests__/transforms/vModel.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ describe('compiler: transform v-model', () => {
6363
expect(generate(root).code).toMatchSnapshot()
6464
})
6565

66+
test('input with v-bind shorthand type should use dynamic model', () => {
67+
const root = transformWithModel('<input :type v-model="model" />')
68+
69+
expect(root.helpers).toContain(V_MODEL_DYNAMIC)
70+
expect(generate(root).code).toMatchSnapshot()
71+
})
72+
6673
test('input w/ dynamic v-bind', () => {
6774
const root = transformWithModel('<input v-bind="obj" v-model="model" />')
6875

0 commit comments

Comments
 (0)