Skip to content

Commit 74151cc

Browse files
committed
chore: add test for nested v-model
1 parent 89f8450 commit 74151cc

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

tests/setValue.spec.ts

+24-3
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,30 @@ describe('setValue', () => {
295295
template: '<div>{{ foo }} {{ bar }}</div>'
296296
})
297297

298+
const NestedInputComponentChild = defineComponent({
299+
props: ['modelValue', 'onUpdate:modelValue'],
300+
template: '<div>{{ modelValue }}</div>'
301+
})
302+
const NestedInputComponent = defineComponent({
303+
props: ['modelValue', 'onUpdate:modelValue'],
304+
template: '<NestedInputComponentChild v-model="modelValue" />',
305+
components: { NestedInputComponentChild }
306+
})
307+
298308
const Component = defineComponent({
299309
template:
300-
'<PlainInputComponent v-model="plain" /><MultiInputComponent v-model:foo="foo" v-model:bar="bar" />',
310+
`<PlainInputComponent v-model="plain" />
311+
<MultiInputComponent v-model:foo="foo" v-model:bar="bar" />
312+
<NestedInputComponent v-model="nested" />`,
301313
data() {
302314
return {
303315
plain: null,
304316
foo: null,
305-
bar: null
317+
bar: null,
318+
nested: null
306319
}
307320
},
308-
components: { PlainInputComponent, MultiInputComponent }
321+
components: { PlainInputComponent, MultiInputComponent, NestedInputComponent }
309322
})
310323

311324
describe('mount', () => {
@@ -324,6 +337,14 @@ describe('setValue', () => {
324337
expect(multiInput.text()).toContain('fooValue')
325338
expect(multiInput.text()).toContain('barValue')
326339
})
340+
341+
it('triggers a normal `v-model` on nested Vue Components', async () => {
342+
const wrapper = mount(Component)
343+
const nested = wrapper.findComponent(NestedInputComponent)
344+
const child = nested.findComponent(NestedInputComponentChild)
345+
await child.setValue('nested-value')
346+
expect(nested.text()).toContain('nested-value')
347+
})
327348
})
328349
describe('shallowMount', () => {
329350
it('triggers a normal `v-model` on a Vue Component', async () => {

0 commit comments

Comments
 (0)